Hi,
Is there an equivalent to this command? I can't seem to find one but there
has to be one.
Jason
Hi,
Is there an equivalent to this command? I can't seem to find one but there
has to be one.
Jason
The if statement will do it, but I think what your looking for is Test-Path
Get-Help Test-Path -full
Brandon Shell
---------------
Blog: http://www.bsonposh.com/
PSH Scripts Project: www.codeplex.com/psobject
g> Hi,
g>
g> Is there an equivalent to this command? I can't seem to find one but
g> there has to be one.
g>
g> Jason
g>
You can use "!" or -not.
Check the help for logical operators:
PS > help about_logical_operator
-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
> Hi,
>
> Is there an equivalent to this command? I can't seem to find one but
> there has to be one.
>
> Jason
>
whoops... I totally forgot I could just link the TechNet site for Test-Path
http://technet.microsoft.com/en-us/l.../bb978701.aspx
Brandon Shell
---------------
Blog: http://www.bsonposh.com/
PSH Scripts Project: www.codeplex.com/psobject
g> Hi,
g>
g> Is there an equivalent to this command? I can't seem to find one but
g> there has to be one.
g>
g> Jason
g>
Hey greatbarrier86,
the exclamation mark is the "not" operator. E.g. "if (!$_.Exist)"
Best Regards,
Jacob Saaby Nielsen
http://www.pipforhelvede.net
gmail: jacob DOT saaby
hotmail (IM): same as gmail
> Hi,
>
> Is there an equivalent to this command? I can't seem to find one but
> there has to be one.
>
> Jason
>
Thanks to all of you!
btw, i like the Test-Path the best. what would be the best way to write that
$Result = test-path -path "C:\Documents and Settings\NicoleH"
if ($Result -eq False)
{
}
or something else? That seems to complex
"Jacob Saaby Nielsen" wrote:
> Hey greatbarrier86,
>
> the exclamation mark is the "not" operator. E.g. "if (!$_.Exist)"
>
> Best Regards,
> Jacob Saaby Nielsen
>
> http://www.pipforhelvede.net
> gmail: jacob DOT saaby
> hotmail (IM): same as gmail
>>
> > Hi,
> >
> > Is there an equivalent to this command? I can't seem to find one but
> > there has to be one.
> >
> > Jason
> >
>
>
if(test-path -path "C:\Documents and Settings\NicoleH"){}
or NOT
if(!(test-path -path "C:\Documents and Settings\NicoleH")){}
Brandon Shell
---------------
Blog: http://www.bsonposh.com/
PSH Scripts Project: www.codeplex.com/psobject
g> Thanks to all of you!
g>
g> btw, i like the Test-Path the best. what would be the best way to
g> write that
g>
g> $Result = test-path -path "C:\Documents and Settings\NicoleH"
g> if ($Result -eq False)
g> {
g> }
g> or something else? That seems to complex
g>
g> "Jacob Saaby Nielsen" wrote:
g>
>> Hey greatbarrier86,
>>
>> the exclamation mark is the "not" operator. E.g. "if (!$_.Exist)"
>>
>> Best Regards,
>> Jacob Saaby Nielsen
>> http://www.pipforhelvede.net
>> gmail: jacob DOT saaby
>> hotmail (IM): same as gmail
>>> Hi,
>>>
>>> Is there an equivalent to this command? I can't seem to find one but
>>> there has to be one.
>>>
>>> Jason
>>>
btw... when your using if() blocks it ALWAYS evaulates to $true or $false...
if $true then {} happens. if $false the Else{} happens. You dont need -eq
so
if($result){"it was true"}else{"it was false"}
Brandon Shell
---------------
Blog: http://www.bsonposh.com/
PSH Scripts Project: www.codeplex.com/psobject
g> Thanks to all of you!
g>
g> btw, i like the Test-Path the best. what would be the best way to
g> write that
g>
g> $Result = test-path -path "C:\Documents and Settings\NicoleH"
g> if ($Result -eq False)
g> {
g> }
g> or something else? That seems to complex
g>
g> "Jacob Saaby Nielsen" wrote:
g>
>> Hey greatbarrier86,
>>
>> the exclamation mark is the "not" operator. E.g. "if (!$_.Exist)"
>>
>> Best Regards,
>> Jacob Saaby Nielsen
>> http://www.pipforhelvede.net
>> gmail: jacob DOT saaby
>> hotmail (IM): same as gmail
>>> Hi,
>>>
>>> Is there an equivalent to this command? I can't seem to find one but
>>> there has to be one.
>>>
>>> Jason
>>>
Brandon,
that is slightly confusing. Can you show me an example of what you mean?
"Brandon Shell [MVP]" wrote:
> btw... when your using if() blocks it ALWAYS evaulates to $true or $false...
> if $true then {} happens. if $false the Else{} happens. You dont need -eq
>
> so
> if($result){"it was true"}else{"it was false"}
>
> Brandon Shell
> ---------------
> Blog: http://www.bsonposh.com/
> PSH Scripts Project: www.codeplex.com/psobject
>
> g> Thanks to all of you!
> g>
> g> btw, i like the Test-Path the best. what would be the best way to
> g> write that
> g>
> g> $Result = test-path -path "C:\Documents and Settings\NicoleH"
> g> if ($Result -eq False)
> g> {
> g> }
> g> or something else? That seems to complex
> g>
> g> "Jacob Saaby Nielsen" wrote:
> g>>
> >> Hey greatbarrier86,
> >>
> >> the exclamation mark is the "not" operator. E.g. "if (!$_.Exist)"
> >>
> >> Best Regards,
> >> Jacob Saaby Nielsen
> >> http://www.pipforhelvede.net
> >> gmail: jacob DOT saaby
> >> hotmail (IM): same as gmail
> >>> Hi,
> >>>
> >>> Is there an equivalent to this command? I can't seem to find one but
> >>> there has to be one.
> >>>
> >>> Jason
> >>>
>
>
I guess he means you can write
if ($Result)
instead of
if ($Result -eq False)
Besides, you should use special variables $true and $false instead of True
and False.
Thanks,
Roman
| Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PowerShell Remoting equivalent of SSH scp | Dave Clarke | PowerShell | 2 | 19 Feb 2009 |
| powershell equivalent | Max2006 | PowerShell | 1 | 26 Jun 2008 |
| VBCRLF equivalent in Powershell? | Victag | PowerShell | 2 | 15 May 2008 |
| PowerShell equivalent for ECHO ON | dtward@gmail.com | PowerShell | 3 | 08 Jan 2007 |
| PowerShell equivalent of StartName | Andrew Watt [MVP] | PowerShell | 1 | 28 Jun 2006 |