create powershell script to get result of get-wmiobject with if and elsif statement
$10-30 USD
Suljettu
Julkaistu yli 5 vuotta sitten
$10-30 USD
Maksettu toimituksen yhteydessä
hello I want to use get-wmiobject to totalphysicalmemory, and numberofcores, and array contain several processes should be compared with get-process result
they should be two conditions true or false for example
if totalphysical memory =< 20158 MB the script should exit
if the numberofcore =< 2 the script should exit otherwise it will contiue
I already coded some lines but of course need fine-tune please find the code below
------------CODE START HERE------------------
$CPU = get-wmiobject -class win32_processor | select-object -property NumberOfCores
#$Mem = get-wmiobject -computer localhost win32_computersystem | select-object @{n="";e={[math]::truncate($[login to view URL] / 1MB)}}
Foreach ($D in $CPU)
{
$CPU = $[login to view URL]
If ($[login to view URL] -le $2)
{Write-Host "$denied"}
Sleep 5
Elseif
#$Mem = $[login to view URL]
($[login to view URL] -le $2048)
{Write-Host "$denied"}
Sleep 5
Else
{Write-Host "$success"}
}
@("[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]","[login to view URL]") | Foreach-object
{
if((Get-Process $_ -ErrorAction SilentlyContinue) -eq $null)
{Write-Host "$success"}
else
{Write-Host "$denied"}
end if
------CODE END HERE-----
Hello Mr. I can help you with this powershell script. I would like to know more about this project. contact me by chat to get more information.
Best Regards