Unable to run scripts
A first thing to test is if you can run the script directly from a PowerShell console. Open pwsh.exe and just try to run the script to see what happens, in many cases this tells you what the problem is and then you can take action on that problem.
Some common issues for not being able to run a script can be found below.
Restricted by Execution policies
PowerShell's execution policy is a safety feature that controls the conditions under which PowerShell loads configuration files and runs scripts. This feature helps prevent the execution of malicious scripts.
Read more here: about_Execution_Policies
File is blocked
Files downloaded from "the internet" can be blocked by Windows. The Unblock-File cmdlet lets you open files that were downloaded from the internet. It unblocks PowerShell script files that were downloaded from the internet so you can run them, even when the PowerShell execution policy is RemoteSigned. By default, these files are blocked to protect the computer from untrusted files.
Read more here: Unblock-File
Misspelled Cmdlet or function
We are all humans and misspell things from time to time.
1 2 3 4 5 6 7 8 |
|
Removing the s in Get-Dates to Get-Date gives us a more correct result when running the script.
1 2 3 |
|