Jump to content
DeployCentral

post-deploy task from network share


martbasi
 Share

Recommended Posts

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

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

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

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...