Hello,
I am trying to get this working in my lab environment, I am getting access denied messages. Its supposed to traverse the c:\tools\server.txt file, and install minecraftinstaller.msi on them all.
Clear-Host
$domainuser = "Basement\administrator"
$domainpassword = 'Password1'| ConvertTo-SecureString -AsPlainText -Force
$domaincredentials = New-Object System.Management.Automation.PSCredential ($domainuser, $domainpassword)
$computers = Get-content 'C:\tools\server.txt'
$Process = 'C:\tools\minecraftinstaller.msi'
Foreach($computer in $computers)
{
Invoke-Command -ComputerName $computer -ScriptBlock {
$Session = New-PSSession -ComputerName $env:COMPUTERNAME
Copy-Item -Path 'C:\tools\minecraftinstaller.msi' -Destination "\\$($Computer)\C$\tools" -ToSession $Session
Start-Process -FilePath $Process -Wait
write-host -ForegroundColor Magenta $env:COMPUTERNAME
}
}
I believe I should have access as I am running the PS windows with a Domain Admin account, and they are all domain members.
Any ideas?
Here is the error output, I cut it off after server1:
> [SERVER1] Connecting to remote server SERVER1 failed with the following error message : Access is denied. For more
> information, see the about_Remote_Troubleshooting Help topic.
> + CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin
> gTransportException
> + FullyQualifiedErrorId : AccessDenied,PSSessionOpenFailed
> + PSComputerName : server1
> Cannot validate argument on parameter 'ToSession'. The argument is null or empty. Provide an argument that is not null
> or empty, and then try the command again.
> + CategoryInfo : InvalidData: (:) [Copy-Item], ParameterBindingValidationException
> + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.CopyItemCommand
> + PSComputerName : server1
>
> Cannot validate argument on parameter 'FilePath'. The argument is null or empty. Provide an argument that is not null
> or empty, and then try the command again.
> + CategoryInfo : InvalidData: (:) [Start-Process], ParameterBindingValidationException
> + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.StartProcessCommand
> + PSComputerName : server1
>
> SERVER1
> [SERVER2] Connecting to remote server SERVER2 failed with the following error message : Access is denied. For more
> information, see the about_Remote_Troubleshooting Help topic.
> + CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin
> gTransportException
> + FullyQualifiedErrorId : AccessDenied,PSSessionOpenFailed
> + PSComputerName : server2
> Cannot validate argument on parameter 'ToSession'. The argument is null or empty. Provide an argument that is not null
> or empty, and then try the command again.
> + CategoryInfo : InvalidData: (:) [Copy-Item], ParameterBindingValidationException
> + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.CopyItemCommand
> + PSComputerName : server2
>
> Cannot validate argument on parameter 'FilePath'. The argument is null or empty. Provide an argument that is not null
> or empty, and then try the command again.
> + CategoryInfo : InvalidData: (:) [Start-Process], ParameterBindingValidationException
> + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.StartProcessCommand
> + PSComputerName : server2
>
> SERVER2