This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $Profilepowershellget = "$env:userprofile\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet\" | |
| if(-Not(Test-Path $Profilepowershellget)){ | |
| New-Item $Profilepowershellget -ItemType Directory | |
| } | |
| $Url = 'https://dist.nuget.org/win-x86-commandline/v5.1.0/nuget.exe' | |
| $OutputFile = "$Profilepowershellget\nuget.exe" | |
| $StartTime = Get-Date | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $NotebookDirectory = "C:\temp\Notebooks" | |
| $targetfilename = "ADSNotebookIndex.ipynb" | |
| $outputLocation = 'C:\temp\Work' | |
| $NotebookPath = "$($NotebookDirectory)\$targetfilename" | |
| $IntroCellText = "# Notebook Index | |
| Click on the code below the workbook you require to generate your custom version to save results in" | |
| $IntroCell = New-ADSWorkBookCell -Text $IntroCellText -Type Text | |
| #check output path exists |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## This PowerShell will create a PowerShell Notebook which will create a PowerShell Notebook! | |
| # This serves no useful purpose :-) | |
| $introCelltext = "# This notebook will create a notebook" | |
| $SecondCelltext = "### Installation | |
| You can install ADSNotebook from the PowerShell Gallery using `Install-Module ADSNotebook` " | |
| $thirdcelltext = " `$introCelltext = ' # This notebook was created by a notebook ' | |
| `$SecondCelltext = '### Installation | |
| You can install ADSNotebook from the PowerShell Gallery using `Install-Module ADSNotebook` ' | |
| `$thirdcelltext = 'Install-Module dbatools' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $tablename = 'BeardTable' | |
| $ColumnMap = @() | |
| $int = New-Object Microsoft.SqlServer.Management.Smo.DataType("Int") | |
| $varchar = New-Object Microsoft.SqlServer.Management.Smo.DataType("varchar") | |
| $datetime = New-Object Microsoft.SqlServer.Management.Smo.DataType("datetime") | |
| $identityColumn = New-Object Microsoft.SqlServer.Management.Smo.Column($table, "Id", $int) | |
| $identityColumn.Nullable = $false | |
| $identityColumn.Identity = $true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ######## POSH-GIT | |
| # with props to https://bradwilson.io/blog/prompt/powershell | |
| # | |
| # | |
| # Now for this to work most beautifully - you will need to have the latest posh-git module | |
| # | |
| # You will also need the MesloLGM Nerd Font Mono font | |
| # from here https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/Meslo/M/Regular/complete/Meslo%20LG%20M%20Regular%20Nerd%20Font%20Complete.ttf | |
| # if you are super nerdy | |
| # or |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $instance = '' | |
| $Databases = '' | |
| $CompressedSize = @{Name='Compressed';Exp={[math]::round($_.CompressedBackupSize/1Tb,3)}} | |
| $Size = @{Name = 'Size';Exp={[math]::Round($_.TotalSize/1Tb,3)}} | |
| ## Get the info | |
| Get-DbaBackupHistory -SqlInstance $instance -Database $databases -Last -Raw | Select Database, Path, $CompressedSize , $Size | |
| #get the total size of files | |
| (Get-DbaBackupHistory -SqlInstance $instance -Database $databases -Last -Raw | Select Database, Path, $CompressedSize | Measure-Object Compressed -Sum).Sum |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Import the dbatools module | |
| Import-Module dbatools | |
| # Set the global values | |
| $instance = 'localhost,15789' | |
| $db = 'WideWorldImporters' | |
| $date = (Get-Date).ToString('yyyy-MM-dd') | |
| $creatorName = 'Beardy McBeardFace' | |
| $cred = Import-Clixml -Path D:\Creds\containersa.xml | |
| $TestClass = 'TestExistence' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
| Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) | |
| choco install chocolatey -y | |
| choco install 1password -y | |
| choco install azure-data-studio -y | |
| choco install azure-functions-core-tools-3 -y | |
| choco install azure-cli -y | |
| choco install bicep -y | |
| choco install chocolatey-core.extension -y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # from https://raw.githubusercontent.com/Microsoft/vsts-tasks/master/Tasks/SqlAzureDacpacDeploymentV1/FindSqlPackagePath.ps1 | |
| # | |
| function Get-SqlPackageOnTargetMachine | |
| { | |
| try | |
| { | |
| $sqlDacPath, $sqlVersion = Locate-HighestVersionSqlPackageWithSql | |
| $sqlVersionNumber = [decimal] $sqlVersion |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [System.Console]::OutputEncoding = [System.Text.Encoding]::ASCII | |
| # borrowing heavily from https://dbatools.io/prompt but formatting the execution time without using the DbaTimeSpanPretty C# type | |
| function Prompt { | |
| if($PSVersionTable.PSVersion.Major -eq 6){ | |
| Write-Host (Get-Date -Format "PS 6 ") -ForegroundColor Yellow -NoNewline | |
| } | |
| elseif($PSVersionTable.PSVersion.Major -eq 5){ | |
| Write-Host (Get-Date -Format "PS 5 ") -ForegroundColor Yellow -NoNewline | |
| } | |
| elseif($PSVersionTable.PSVersion.Major -eq 7){ |