Associate
- Joined
- 15 Jul 2005
- Posts
- 1,230
- Location
- UK
Hi all,
I have been learning Powershell this week and im slowly getting grips with it.
I cant seem to get the if statements working correctly as they just seem to skip them. the below script I wrote should just output some text if the UT4 folder is on my C:\ drive, but I keep getting the output of "thats a negative ghost rider! "
I am guessing that the $whole.name part is wrong. Am I correct in saying that the dot after the variable should be the name of the membertype? I am getting the .name part when I run get-childitem | get-member
I am also having the same problem when I wrote this script
Please note I don't have any experience in VB, perl etc, this is my first scripting language so my query is probably a rookie one!
I have been learning Powershell this week and im slowly getting grips with it.
I cant seem to get the if statements working correctly as they just seem to skip them. the below script I wrote should just output some text if the UT4 folder is on my C:\ drive, but I keep getting the output of "thats a negative ghost rider! "
$path1 = "c:\"
$foldername = "UT4"
$whole = Get-ChildItem -Path $path1
if ($whole.name -eq $foldername)
{ Write-Host -ForegroundColor "green" Folder found! }
else
{ Write-Host -ForegroundColor "red" thats a negative ghost rider! }
I am guessing that the $whole.name part is wrong. Am I correct in saying that the dot after the variable should be the name of the membertype? I am getting the .name part when I run get-childitem | get-member
I am also having the same problem when I wrote this script
$wmiclass = "Get-WmiObject win32_processor"
if ($wmiclass.NumberOfCores -eq 4)
{Write-Host -ForegroundColor "green" Quad Core Baby!}
elseif ($wmiclass.NumberOfCores -eq 2)
{Write-Host -ForegroundColor "green" Dual Core Baby!}
elseif ($wmiclass.NumberOfCores -eq 1)
{Write-Host -ForegroundColor "green" Single Core Loser!}
else {Write-Host you have no CPU!}
Please note I don't have any experience in VB, perl etc, this is my first scripting language so my query is probably a rookie one!