Jump to content

PowerShell script taking WEEKS to finish


Recommended Posts

Posted (edited)

I'm trying to give our Service Desk guys full control of our user profile and home directories by running a PowerShell script. This is the script I'm running:

 

$Acl = (Get-Item "\\MYSERVER01\Profiles$").GetAccessControl('Access')
$Ar = New-Object System.Security.AccessControl.FileSystemAccessRule("MYDOMAIN\ServiceDesk", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
$Acl.SetAccessRule($Ar)
Set-Acl -path "\\MYSERVER01\Profiles$" -AclObject $Acl

I am running it on a total of 90 servers. The problem is the script has now been running for two weeks and is only around half way through! Running the above command on one server individually takes hours and hours. There isn't a lot of data in the users profile and home directories either.

I can't work out why it's taking so long for the script to run!? What am I doing wrong?

Edited by LeeAU
Posted
Are you running it from one workstation and calling the commands on remote folders on each server? If so I would utilise powershell remoting so that the commands are running on the servers directly.
  • Thanks 1
Posted
What OS / ps version you using? I seem to remember that this could be painfully slow but would need to look at it again to be sure.

 

Windows 10 Pro x64 and PowerShell 5.1.17134.407

 

 

Are you running it from one workstation and calling the commands on remote folders on each server? If so I would utilise powershell remoting so that the commands are running on the servers directly.

 

Yes, from my workstation. How would one go about this? Is it just an extra line I need to input? :)

Posted
Are you running it from one workstation and calling the commands on remote folders on each server? If so I would utilise powershell remoting so that the commands are running on the servers directly.

Googled it and managed to get it working, it is much faster! thanks a lot. This will come in handy in future scripts :D

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...