PowerShell Function之獲取process和NIC信息

直接上腳本了。

#獲取進程信息
function Get-InfoProc {
param(
$ComputerName
)
$procs = Get-WmiObject -class Win32_Process -ComputerName $ComputerName
foreach ($proc in $procs) {
$props = @{'ProcName'=$proc.name;
'Executable'=$proc.ExecutablePath}
New-Object -TypeName PSObject -Property $props
}
}
#或者NIC信息
function Get-InfoNIC {
param(
$ComputerName
)
$nics = Get-WmiObject -class Win32_NetworkAdapter -ComputerName $ComputerName -Filter "PhysicalAdapter=True"
foreach ($nic in $nics) {
$props = @{'NICName'=$nic.servicename;
'Speed'=$nic.speed / 1MB -as [int];
'Manufacturer'=$nic.manufacturer;
'MACAddress'=$nic.macaddress}
New-Object -TypeName PSObject -Property $props
}
}
以上腳本信息,請大家參考。

發佈了46 篇原創文章 · 獲贊 7 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章