Tuesday, January 31, 2017

PowerShell : Trust network share to load modules & ps1


Do you have a central network share, where you store all the scripts or PowerShell modules ?
What happens if you try to run the script from a network share ? or if you have scripts (local) which invoke scripts or import PowerShell modules stored on this network share ?

Well you would see a security warning like below (Note - I have set execution policy as 'Unrestricted' not 'bypass' here):

Run a .ps1 from the network share

Well this is a similar warning, which you get when you download scripts from Internet.
As the message says run Unblock-File cmdlet to unblock the script and then run it, let's try it.