Jump to content

Recommended Posts

Posted
Yeah, still save it as a ps1 file, the coding I added is a native PowerShell if statement. :)

 

Ok, thank you, that makes sense.

 

In terms of adding to a machine startup policy under the PowerShell section, I think this is what I have already done...

 

gpol.PNG

 

Will this not just bring up the same error I get when running manually on Powershell ISE when it says running of scripts is disabled?

 

If I manually run your new code on ISE, it brings up the same error I got before.

Running your command prompt line works a treat though, but I don't think I can add that to Group Policy (powershell.exe –ExecutionPolicy Bypass "\\fty-sr-001\applic$\DotNetFix\DotNetFix.ps1)

Posted (edited)
Ok, thank you, that makes sense.

 

In terms of adding to a machine startup policy under the PowerShell section, I think this is what I have already done...

 

[ATTACH=CONFIG]46636[/ATTACH]

 

Perfect :)

 

Will this not just bring up the same error I get when running manually on PowerShell ISE when it says running of scripts is disabled?

 

If I remember correctly, as it's pushed via GPO, it will run as admin... and I believe not need the allowed script level to change...

 

...but if that doesn't work, you could always execute it with a .cmd file instead with the command:

 

powershell.exe –ExecutionPolicy Bypass "\\fty-sr-001\applic$\DotNetFix\DotNetFix.ps1"

 

If I manually run your new code on ISE, it brings up the same error I got before.

Running your command prompt line works a treat though, but I don't think I can add that to Group Policy (powershell.exe –ExecutionPolicy Bypass "\\fty-sr-001\applic$\DotNetFix\DotNetFix.ps1")

 

Yeah it won't run in PowerShell or ISE unless you tell it to change your allowed script level to RemoteSigned or lower.

(i.e. typing the following command into PowerShell before running subsequent scripts)

 

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

 

More Info: https://technet.microsoft.com/en-us/library/ee176961.aspx

Edited by DJ-1701
  • Thanks 1
Posted
Perfect :)

 

 

 

If I remember correctly, as it's pushed via GPO, it will run as admin... and I believe not need the allowed script level to change...

 

...but if that doesn't work, you could always execute it with a .cmd file instead with the command:

 

powershell.exe –ExecutionPolicy Bypass "\\fty-sr-001\applic$\DotNetFix\DotNetFix.ps1"

 

 

 

Yeah it won't run in PowerShell or ISE unless you tell it to change your allowed script level to RemoteSigned or lower.

(i.e. typing the following command into PowerShell before running subsequent scripts)

 

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

 

More Info: https://technet.microsoft.com/en-us/library/ee176961.aspx

 

Thank you so much for the explanation, it all makes sense.

Hmm, tried restarting a test system.... it still is not working, and the system does not have it installed.

I have looked through the Application Windows log and can't see anything.

 

Maybe I should try your suggestion of using a .cmd file. If I were to go down this route, where would be best to save the .cmd file and link to it in the policy? Could it be done as a startup script through the Active Directory?

Posted
Thank you so much for the explanation, it all makes sense.

Hmm, tried restarting a test system.... it still is not working, and the system does not have it installed.

I have looked through the Application Windows log and can't see anything.

 

Maybe I should try your suggestion of using a .cmd file. If I were to go down this route, where would be best to save the .cmd file and link to it in the policy? Could it be done as a startup script through the Active Directory?

 

I usually put the script in the GPO directory, which you can get to by clicking the Show Files... button on the Startup Properties.

Posted
I usually put the script in the GPO directory, which you can get to by clicking the Show Files... button on the Startup Properties.

 

Ok, so maybe I could try a .cmd script in the startup GPO director which as you rightly say, can be found by clicking show files.

 

I could make the CMD file contain the following:

powershell.exe –ExecutionPolicy Bypass "\\fty-sr-001\applic$\DotNetFix\DotNetFix.ps1"

 

How does that sound?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...