简体   繁体   中英

Powershell output for multiple dhcp servers

I am trying to get the mibinfo for multiple dhcp servers in our infrastructure. My problem is that when i run the command

invoke-command -computername $dhcpserver -credential $Cred -scriptblock{netsh dhcp server show mibinfo}

I get MIBinfo for all the servers, but i don't get the name of the server in the output. So i need a way where i get the output as

Server1 mibinfo

server2 mibinfo

($dhcpserver has the list of all the dhcp servers.)

Is $dhcpserver an array of strings? I didn't know Invoke-Command could do this...

If so, try this:

Foreach ($server in $dhcpserver) { 
    $mibOutput = invoke-command -computername $server -credential $Cred -scriptblock{netsh dhcp server show mibinfo}
    Write-Output "$server $mibOutput"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM