talksr Posted December 8, 2017 Author Posted December 8, 2017 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... 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)
snagrat Posted December 8, 2017 Posted December 8, 2017 Create a batch file with the command in and then put the batch file as a startup script
DJ-1701 Posted December 8, 2017 Posted December 8, 2017 (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 December 8, 2017 by DJ-1701 1
talksr Posted December 8, 2017 Author Posted December 8, 2017 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?
DJ-1701 Posted December 8, 2017 Posted December 8, 2017 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.
talksr Posted December 11, 2017 Author Posted December 11, 2017 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?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now