martbasi Posted September 29, 2015 Report Share Posted September 29, 2015 Hi, I'm going to need to run a powershell script from a network share as deployment task "Upon first boot as system", ie, before first login. I'm wondering if anyone can tell me: Since the PC will be in the domain at this point, if I give the group "mydomain\domain computers" read/execute permissions on the network folder, would that allow the system account to run the remote script directly via UNC path? (eg, \\servername\foldername\script.ps1 ) Link to comment Share on other sites More sharing options...
SmartDeploySupport Posted September 29, 2015 Report Share Posted September 29, 2015 Hello, We don't recommend running scripts off network shares. We have had some customers be successful, but there are times that the network drivers aren't initialized in time for the script to run. It's a timing issue. We would recommend putting the script in your pack or on the image itself. Thanks, SmartDeploy Support Link to comment Share on other sites More sharing options...
martbasi Posted September 29, 2015 Author Report Share Posted September 29, 2015 Ok, thinking out loud ... so perhaps a local kick-off script could go into the captured image, and it could repeatedly test-path ... and once the share is accessible, pull the remote scripts down and execute locally. Link to comment Share on other sites More sharing options...
martbasi Posted October 5, 2015 Author Report Share Posted October 5, 2015 In case it's of help to someone in future ... Probably someone can do this better than me, but here's the powershell code i put in a script that is baked into the captured image. The .ps1 is called by a batch file since I also use that to first set the Remote Execution policy to unrestricted. Batch file is run "Upon first boot as system", uses the script below to check if the file server is reachable. When it is, it then goes on to robocopy all the desired scripts and installers to a local path, then executes them. # Variables $RemoteBox = "myservername" $RemoteBoxTest = Test-Connection -Count 1 -ComputerName $RemoteBox -Quiet $RemoteBoxTestCount = 1 $RetriesMax = 7 $RetriesInterval = 10 # Check if we're online with a Test-Connection to the server # If we get no replies, we'll retry every 10sec for up to 1 minute While ($RemoteBoxTest -ne $true -and $RemoteBoxTestCount -lt $RetriesMax) { Start-Sleep -Seconds $RetriesInterval $RemoteBoxTestCount++ $RemoteBoxTest = Test-Connection -Count 1 -ComputerName $RemoteBox -Quiet } if ($RemoteBoxTest -ne $true -and $RemoteBoxTestCount -ge $RetriesMax) { throw "$RemoteBox unreachable by attempt number $RemoteBoxTestCount" } else { #Do all the things! } Link to comment Share on other sites More sharing options...
fllorente Posted October 14, 2015 Report Share Posted October 14, 2015 That's a nice and smart solution, Martbasi. Thanks for sharing :-) -- Javier Llorente Link to comment Share on other sites More sharing options...
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