У меня есть рабочий код, чтобы проверить дом на сумму оперативной памяти на каждую единицу.Я даю ему IP-адрес, и он возвращает количество оперативной памяти и некоторые другие вещи, отформатированные.Могу ли я просто добавить готовый файл в этот файл, чтобы он принимал список IP-адресов из .txt или .csv?
Я пытался вставить этот код, который у меня есть, в другой файл, который запускается из списка, но я продолжаю получать ошибки.
param([string]$fileInput,[string]$fileOutput )
If ( $fileInput -eq "" -OR $fileOutput -eq ""){
$list = Import-Csv $fileInput -Header name, licenseKey, keyStatus
foreach( $computerName in $list){
export-csv -InputObject $computerName -append $fileOutput -Encoding utf8
}
}
Я не уверен, что правильное расположение этих строк вмой код.
write-host ""
$strComputer = Read-Host "Enter Computer Name to list memory slot information"
$colSlots = Get-WmiObject -Class "win32_PhysicalMemoryArray" -namespace "root\CIMV2" -computerName $strComputer
$colRAM = Get-WmiObject -Class "win32_PhysicalMemory" -namespace "root\CIMV2" -computerName $strComputer
$NumSlots = 0
write-host ""
$colSlots | ForEach {
“Total Number of Memory Slots: ” + $_.MemoryDevices
$NumSlots = $_.MemoryDevices
}
write-host ""
Read-Host "Press Enter to continue"
$SlotsFilled = 0
$TotMemPopulated = 0
$colRAM | ForEach {
“Memory Installed: ” + $_.DeviceLocator
“Memory Size: ” + ($_.Capacity / 1GB) + ” GB”
$SlotsFilled = $SlotsFilled + 1
$TotMemPopulated = $TotMemPopulated + ($_.Capacity / 1GB)
# if ($_.Capacity = 0)
# {write-host "found free slot"}
}
write-host ""
write-host "=== Summary Memory Slot Info for computer:" $strComputer "==="
write-host ""
If (($NumSlots - $SlotsFilled) -eq 0) {
write-host "ALL Slots Filled, NO EMPTY SLOTS AVAILABLE!"
}
write-host ($NumSlots - $SlotsFilled) " of " $NumSlots " slots Open/Available (Unpopulated)"
write-host ($SlotsFilled) " of " $NumSlots " slots Used/Filled (Populated)."
write-host ""
write-host "Total Memory Populated = " $TotMemPopulated "GB"
#