Script Commands
Script commands are a set of executable PowerShell cmdlets stored in a file with the .ps1 extension
param (
[int] $variable1,
[int] $variable2
)
$variable3=$variable1+$variable2;
$variable3
You can use any text editor to write a PowerShell Script file, not just Notepad
Then the PowerShell script Add-Num.ps1 can be executed using .\ or ./, as shown in Figure 2-11.
Set-Location C:\DBAScripts
.\add-num.ps1 100 200
./add-num.ps1 10 200
When executing the script, if PowerShell returns the warning message ‘‘Script cannot be loaded because
execution of script is disabled,’’ then execute the following command
Set-ExecutionPolicy Unrestricted
when you execute this command then you will get no restricted ... and you can run all type scripts
Script commands are a set of executable PowerShell cmdlets stored in a file with the .ps1 extension
param (
[int] $variable1,
[int] $variable2
)
$variable3=$variable1+$variable2;
$variable3
You can use any text editor to write a PowerShell Script file, not just Notepad
Then the PowerShell script Add-Num.ps1 can be executed using .\ or ./, as shown in Figure 2-11.
Set-Location C:\DBAScripts
.\add-num.ps1 100 200
./add-num.ps1 10 200
When executing the script, if PowerShell returns the warning message ‘‘Script cannot be loaded because
execution of script is disabled,’’ then execute the following command
Set-ExecutionPolicy Unrestricted
when you execute this command then you will get no restricted ... and you can run all type scripts