- Details
- Written by: Stanko Milosev
- Category: Powershell
- Hits: 4330
To set the working directory for powershell add the following command to your PowerShell profile:
Set-Location c:\scripts
To Create a PowerShell Profile
1. Create a folder in your Documents folder called WindowsPowerShell in my case that is C:\Users\pera.virtualOne\Documents\WindowsPowerShell
2. Create a file called profile.ps1 inside this folder
3. Add any desired initialization commands to this file (Set-Location c:\scripts) and save it
4. Every time you launch PowerShell, the profile script will be executed
Copy / pasted from here.
- Details
- Written by: Stanko Milosev
- Category: Powershell
- Hits: 4087
If your powershell looks like:
param($myTestParameter) function TestParameter() { Write-Host "Parameter is: $myTestParameter" }
Saved as myTest.ps1, for example.
Then to use parameter, call script like:
. .\myTest.ps1 -myTestParameter "Test parameter"
Notice that myTestParameter is without dollar sign, and then you can call function like TestParameter, result should be something like:
Parameter is: Test parameter
Example download from here.