Hi all, I am beginner of powersheel, I need to clear the file of my server automically by date (14 days), and strange is I think the code is fine I using Powersheel ISE and can run the code line by line working perfect(f8). But if I run the script (f5), i got "cannot be loaded because running script is disable on the system" My code is as below.
Any idea? Thanks.
Set-ExecutionPolicy unrestricted -force
F5 in ISE requires, the script to be saved and running a script is restricted by default as you execution policy is restricted. you have to Set it before running the script and not within the script.
Open a PowerShell (with elevated permission) and run
Set-ExecutionPolicy RemoteSigned -force
I suggest you to take a look at the documentation of about_execution_policies
and when you post code in the forum, use code posting tag(pre).
You must be logged in to reply to this topic.