Hello, I'm trying to troubleshoot this script. Any help would be appreciated.
The first error I'm getting is "Access Denied" when attempting to copy the .msi file. The file path gets created but then the file doesn't copy. I've checked the permissions on the folder and they appear to be correct. Also, the folders are created with the ReadOnly attribute.
The next error I get is:
Connecting to remote server servername failed with the following error message : WinRM cannot complete the operation. Verify that the specified computer name is valid, that the computer is accessible over the network, and that a firewall exception for the WinRM service is enabled and allows access from this computer. By default, the WinRM firewall exception for public profiles limits access to remote computers within the same local subnet. For more information, see the about_Remote_Troubleshooting Help topic. I've even made sure the WinRM service was started on the remote machine. The firewall is not running on the domain profile.
+ CategoryInfo : OpenError: (servername:String) [], PSRemotingTransportException
+ FullyQualifiedErrorId : WinRMOperationTimeout,PSSessionStateBroken
$computername = Get-Content 'c:\temp\comp.txt'
$sourcefile = "\\servername\share\test.msi"
#This section will install the software
foreach ($computer in $computername)
{
$destinationFolder = "\\$computer\C$\download"
#This section will copy the $sourcefile to the $destinationfolder. If the Folder does not exist it will create it.
if (!(Test-Path -path $destinationFolder))
{
New-Item $destinationFolder -Type Directory
}
Copy-Item -Path $sourcefile -Destination $desinationfolder -Force
Invoke-Command -ComputerName $computer -ScriptBlock { & cmd /c "msiexec.exe /i c:\download\test.msi" /qb}
}
D Cobb Windows IT Pro