0

Good morning,

I have the following script and it works just fine, but instead of hard coding 100 servers I want it to read the servers from a .txt file. Here is my code any help would be great:

[string[]]$servers = 'Server1,Server2,Server3' -split ','

$credential = Get-Credential 

Invoke-Command -ComputerName $servers -Credential $credential -ScriptBlock {

Get-ItemProperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate 

} | Format-Table PSComputerName, DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize | Out-File C:\Temp\SoftwareListByServer.txt

1 Answer 1

3
$servers = get-content servers.txt

Where servers.txt contains (only) a list of servers one per line.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.