Closed

create powershell script to get result of get-wmiobject with if and elsif statement

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-----

Skills: C Programming, C++ Programming, Powershell, Shell Script, Software Architecture

See more: centos create startup script, create logon script server 2003 sets background, action script result java class, powershell if contains, powershell if string equals, powershell if not equal, how to write if statement powershell, powershell if elseif, powershell if statement multiple conditions, powershell if statement variable, powershell if equals, create database script, powershell script create multiple users, powershell script create account, powershell create user script excel, powershell script create active directory user accounts excel, powershell script create mailbox, create excel macro run powershell script, powershell script create accounts, powershell script create ad users excel file

About the Employer:
( 0 reviews ) Beirut, Lebanon

Project ID: #17781908

10 freelancers are bidding on average $24 for this job

vano101

Hello I have extensive experience with WMI and powershell. I am sure this project is just piece of cake for me.

$25 USD in 1 day
(1701 Reviews)
7.7
ITPyramid85

hello,how are you. i read your bid carefully. i am c/c++ expert and have full experience for 10 years. c++ language is my top skill. i can provide most quality and high speed. if you want to success, please contact More

$25 USD in 1 day
(12 Reviews)
6.8
dany3j

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

$30 USD in 3 days
(23 Reviews)
4.3
venkat071292

Greetings!! I am an Microsoft certified professional with expertise in Windows Powershell I have done various automation projects using Powershell for the past 4+ years. I can accomplish the given task using W More

$30 USD in 3 days
(21 Reviews)
4.3
sabyasai1

This letter is to express my interest in your posting on Freelancer for an experienced Developer(Powershell Script) It will be my pleasure if I can build this script for [login to view URL] you for your time and consideration More

$25 USD in 1 day
(3 Reviews)
3.2
$20 USD in 1 day
(6 Reviews)
2.7
$20 USD in 1 day
(2 Reviews)
1.9
$15 USD in 3 days
(0 Reviews)
0.0
$25 USD in 3 days
(0 Reviews)
0.0
christejeda

Hello, This can easily be done. Please see my GitHub page and my work wit powershell. [login to view URL]

$25 USD in 1 day
(0 Reviews)
0.0