could you help me with, i'm trying to get the computer name and the output from this command below in a txt file.
for /f %1 in (user_plant.txt) do >>\\brspd010\\c$\\users\\machael1\\desktop\\nic.txt ((wmic /node:%i computersystem get caption | more) & (powershell -command "& {Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName %i. | Format-Table -Property IPAddress, DHCPEnabled}))
the command powershell when i run without the rest, it's works fine, but when i try to put together not work.
userplant.txt has: brspd001 brspd002 ...
My needly is: A txt file with Name of machine and IPV4,DHCP status as the same showed when i run only the powershell command. example:
Computername: BRSPD001 IP 172 ... DHCP Enabled true.
or someone like it.
could you help me?
This is probably better done in pure PowerShell. Assuming one computername per line in user_plant.txt:
foreach ($Computer in (Get-Content -Path user_plant.txt)) {
$c = Get-WMIObject -ComputerName $Computer -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled = $true"
"ComputerName: {0} IP: {1} DHCPEnabled {2}" -f $Computer,$C.IPAddress[0],$C.DHCPEnabled | Add-Content -Path "\\brspd010\c$\users\machael1\desktop\nic.txt"
}
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.