IT:AD:Code:HowTo:PowerShell:Setup For Development
Summary
Open the folder containing your scripts.
Process
- Start IT:AD:Code in a new directory.
Ctrl+Shift+P, thenuserto edit the usersettings.jsonfile for that folder.- On the right, provide the following:
// Place your settings in this file to overwrite the default settings
{
"editor.lineNumbers": true,
"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe",
"powershell.developer.powerShellExePath": "C:\\Windows\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe"
}
- Create a
test.ps1file. Add a method
- example
function Get-Hello(){ Write-Host "Hi!" }
Using the Execution Environment
To run it, you have to open a Execution Environment:
# Existing: Ctrl-` # or new one: Ctrl-Shift-`
Load the file:
./YourFile.ps1
Then run it.
Gay-Hello
Using Pester
But loading up files on the command line is a PIA.
Debugging
Pretty straightforward1).