I have the following PowerShell script, that I want to run from within my C# application.
$adapters=(gwmi win32_networkadapterconfiguration )
Foreach ($adapter in $adapters){
Write-Host $adapter
$adapter.settcpipnetbios(2)
}
$nics=([wmiclass]'Win32_NetworkAdapterConfiguration')
Foreach($nic in $nics){
Write-Host $adapter
$nic.enablewins($false,$false)
}
This is what I tried so far, using the "using System.Management.Automation;," but the script is not working. Can someone point me in the right direction?
PowerShell ps = PowerShell.Create();
ps.AddCommand("Get-Process");
ps.AddArgument("$adapters=(gwmi
win32_networkadapterconfiguration )");
ps.AddArgument("Foreach($adapter in $adapters){");
ps.AddArgument(" Write - Host $adapter");
ps.AddArgument("$adapter $adapter.settcpipnetbios(2)}");
//WINS LMHOSTS lookup
ps.AddArgument("$nics = ([wmiclass]'Win32_NetworkAdapterConfiguration')");
ps.AddArgument("Foreach($nic in $nics){");
ps.AddArgument(" Write - Host $adapter");
ps.AddArgument("$nic.enablewins($false,$false)}");