PowerShell is Microsoft’s recommended Windows scripting language. Although the DOS based command language used in batch (.bat) files will continue to be supported PowerShell is the recommended replacement.
Pages on PowerShell
-
Run Tabcmd from Batch file and PowerShell Script Compares .bat file scripts to PowerShell scripts.
In this section
-
Deleting Old Files After Days Deletes older files such as old log files.
-
Execution Policy in PowerShell PowerShell's default security level will only run signed scripts. The execution policy can be changed. Error Message: “Cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about-signing".
-
Replace Text in String PowerShell has a replace method and a -replace operator.
-
If ... Else in PowerShell -
Install the SQL Server PowerShell Module from PowerShell Gallery -
Logging Jobs with Start-Transcript Powershell (.ps1) scripts supports much better logging than SQL Server Agent or Windows Task Scheduler (WTS). The Start-Transcript command captures script and program output at the script level. This level of logging catches error messages that other logging strategies miss. Logging features in application programs for instance don’t begin to capture error messages until sometime after the application program begins running. In contrast the job logging in SQL Server Agent and WTS is very minimal.
-
Run .bat File From PowerShell .ps1 Script -
Unblock PowerShell Command -
new--Microsoft PowerShell -
How to Run PowerShell Scripts -
Running PowerShell Script from Scheduler -
Run Tabcmd from Batch file and PowerShell Script The same procedure written as DOS Batch (.bat) file and as a PowerShell script (.ps1).
-
Create Windows Environment Variables with PowerShell How to create environment variables and assign values to them with PowerShell.
Default PowerShell Security
Some versions & installations of PowerShell have default security configurations which may prevent running PowerShell scripts. (There is more Windows security on PowerShell scripts than .bat files!)
There are ways to reconfigure PowerShell security that removes most restrictions. Ask your IT security people for the PowerShell security policy.
Documentation is a work-in-progress.
-
Deleting Old Files After Days -
Execution Policy in PowerShell -
Replace Text in String -
If ... Else in PowerShell -
Install the SQL Server PowerShell Module from PowerShell Gallery -
Logging Jobs with Start-Transcript -
Run .bat File From PowerShell .ps1 Script -
Unblock PowerShell Command -
new--Microsoft PowerShell -
How to Run PowerShell Scripts -
Running PowerShell Script from Scheduler -
Run Tabcmd from Batch file and PowerShell Script -
Create Windows Environment Variables with PowerShell
Layout tests
Left
Right
Left
Middle
Right