This file contains 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-Module -Name Pester | |
Import-Module -Name ScriptAnalyzer | |
Describe 'Script Analyzer Tests' { | |
Context 'Script Analyzer' { | |
$analysis = Invoke-ScriptAnalyzer -Path '.\MyScript.ps1' | |
$rules = Get-ScriptAnalyzerRule | |
This file contains 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
# List of available PowerShell Accelerators to use in functions | |
[psobject].Assembly.GetType('System.Management.Automation.TypeAccelerators')::Get | sort-Object -Property Value |
This file contains 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
// File -> Preferences -> Settings : Settungs.json | |
// Update to the below code (Starting line 4, added alternates that may come in useful at other times, at present you cant choose which to load :( | |
{ | |
// 64-bit PowerShell if available, otherwise 32-bit | |
"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe", | |
// Git Bash | |
//"terminal.integrated.shell.windows3": "C:\\Program Files\\Git\\bin\\bash.exe", | |
// 64-bit cmd if available, otherwise 32-bit | |
//"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\cmd.exe" |
This file contains 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
SELECT 'Pre Deployment Changes',name , | |
is_trustworthy_on , | |
SUSER_SNAME(owner_sid) AS [DBOwner] | |
FROM sys.databases | |
WHERE name = 'databaseName'; | |
USE [master]; | |
GO | |
ALTER DATABASE databaseName SET READ_WRITE WITH ROLLBACK IMMEDIATE; | |
GO |
This file contains 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
$env:ServerName = "MyServer" | |
$env:JenkinsUser = "domain\login" | |
$env:JenkinsPassword = "SuperSecretPassword" | |
## Ivoke OS Pester test output to OSreport.xml | |
Invoke-Pester -Script @{Path ='C:\GIT\DBA\Build\Pester\SQL Server OS.test.ps1'; Parameters = @{ServerName = $($env:ServerName); JenkinsUser = $($env:JenkinsUser) ; JenkinsPassword = $($env:JenkinsPassword)}} -OutputFile OSreport.xml -OutputFormat NUnitXml | |
## Push data into SQL Server via DBATools | |
$output = Parse-PesterXML -XMLFile ./OSreport.xml -Server $env:ServerName | Out-DbaDataTable | |
Write-DbaDataTable -SqlServer PRD-SQL-INT01 -InputObject $output -Table admin.dbo.pesterresults -AutoCreateTable |
This file contains 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
# help | |
chef --help | |
chef generate --help | |
# Create Chef-Repo | |
Chef generate repo chef-repo | |
# Create new Cookbook | |
Chef generate cookbook ax_SQLServer |
This file contains 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
# list all cookbooks on Chef Server | |
knife cookbook list | |
# List all cookbooks on Chef Server (with version info) | |
knife cookbook list -a | |
# download all cookbooks from the Chef Server | |
knife download cookbooks | |
# Upload all cookbooks from workstation to Chef Server |
This file contains 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
## list kitchen test state | |
kitchen list | |
## creates vm based on kitchen.yml | |
kitchen create | |
## applies cookbook to vm | |
kitchen converge | |
## kitchen verify runs tests from folder: |
This file contains 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
# help | |
knife role --help | |
# List all roles | |
knife role list | |
# Details of role | |
knife role show myrole | |
# Create a role from a file |
This file contains 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
## list the run_lists on a node | |
knife node run_list list <NODE> -r | |
## Set a run_list | |
knife node run_list <NODE> 'recipe[iis]' | |
## Add an item before | |
knife node run_list add <NODE> recipe[basicconfig::join_ad] -b recipe[iis] | |
## Add an item after |
OlderNewer