I was hoping somebody could help me with the below script. When I use Read-Host it prompts to enter a value which is what I expect and want. The problem is I need to make a change on 80 servers and was looking for a way not to enter the IP or name 80x.
Hard coding is not an option since the info will change as the objects get updated.
I would appreciate some help.
Just want to add my skills are lacking and I am a beginner. Please be patience …
$servers = @(“server1”,“server2”)
foreach($member in $servers){
Invoke-Command -ComputerName $member -ScriptBlock `
{
$server = hostname
$a = Read-Host -Prompt “IP”
$printerip = “$a”
$port = ([WMICLASS]“\$server\ROOT\cimv2:Win32_TCPIPPrinterPort”).createInstance()
$port.Name=$printerip
$port.SNMPEnabled=$false
$port.Protocol=1
$port.HostAddress=$printerip
$port.Put()
$port
$b = Read-Host -Prompt “Name”
$p=gwmi win32_printer -filter “Name=‘$b’”
$p.PortName= $printerip
$p.Put()
}}