I've been searching all day for something I thought would be relatively simple, but I've come up with no answers. I'm writing a Powershell script as a developer to give to an IT Ops employee to do an automated deployment of one of our web applications to production servers. Currently, the script requires Ops to manually log in to the remote target servers through Windows Explorer before running the script. I would like to have the script automatically try to connect to specified servers and prompt whoever is running it for credentials. Is there a Powershell command to log in to a server without needing to specify a path to a share?
Asked
Active
Viewed 219 times
-1
-
You may want to look into `Invoke-Command`, depending on exactly what you're needing. – Nick Jan 10 '18 at 18:27
-
I don't think Invoke-Command would work for what I want. I'm not trying to execute commands on the remote server itself. The script is just doing file copies from one server to another – Mike Jan 10 '18 at 18:57
-
I am no Powershell man, but I suppose you could [skim this answer](https://stackoverflow.com/questions/46637094/how-can-i-find-the-upgrade-code-for-an-installed-msi-file/46637095#46637095) (quite a bit down the page). No guarantees, just the first thing that came to my mind. [Maybe skim this too](https://stackoverflow.com/questions/6239647/using-powershell-credentials-without-being-prompted-for-a-password). I suppose you have already read all of this. – Stein Åsmul Jan 10 '18 at 22:58
1 Answers
0
Not sure this will fit what you are looking for but it is a Powershell script I have used for doing remote installations of the Microsoft SCCM client. It makes use of PsExec so that would be a requirement. Maybe this will get you started and you can find your path forward from there.
$Computer = Read-Host -Prompt 'Input Computer Name'
If (Test-Connection -ComputerName $Computer -Count 1 -ea 0 -Quiet) {
net use S: \\$Computer\C$
New-Item -ItemType Directory -Path S:\SCCM
Copy-Item C:\SCCM\*.* S:\SCCM
C:\Sysinternals\PsExec.exe \\$Computer C:\SCCM\ccmsetup.exe /source:"C:\SCCM" /[your server details] /forceinstall
Remove-Item S:\SCCM\*.* -Recurse
Remove-Item S:\SCCM -Recurse
net use S: /Delete
} else {
"$Computer is not online"
}
As long as this script is run with elevated privileges, I have not had it fail with installations and it does not require any remote logins.

Stephen Parker
- 11
- 1
- 6