![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | is there an 'exists-item' function? Hi, I'm just doing my first steps into Powershell and just stumbled over a point where I want to know if an item with a given name exists. I managed to write a function: function exist-item($s) { $local:a = (get-item $s -ea silentlyContinue) return (($a -ne $null) -and ($a -ne '')) } but this already existed in all command interpreters (even DOS) I used before. What about PS? Regards Rainer |
My System Specs![]() |
| | #2 (permalink) |
| Guest | RE: is there an 'exists-item' function? Try something like Test-Path "C:\scripts\monad\teched.zip" returns true if exists and false if doesn't -- Richard Siddaway Please note that all scripts are supplied "as is" and with no warranty "Rainer Prem" wrote: > Hi, > > I'm just doing my first steps into Powershell and just stumbled over a point > where I want to know if an item with a given name exists. > > I managed to write a function: > > function exist-item($s) > { > $local:a = (get-item $s -ea silentlyContinue) > return (($a -ne $null) -and ($a -ne '')) > } > > but this already existed in all command interpreters (even DOS) I used before. > What about PS? > > Regards > Rainer |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ReadyBoost - Cache Exists | RugRat | Vista General | 10 | 04-14-2008 10:32 PM |
| if a file exists | NeilOz | PowerShell | 6 | 01-03-2008 02:33 AM |
| If file exists loop | ryanlsanders@gmail.com | PowerShell | 5 | 08-16-2007 10:05 AM |
| BUG: Redirecting function contents to a file truncates function lines at the width of the console | Adam Milazzo | PowerShell | 2 | 08-11-2006 10:58 PM |
| How to get the item count inside a function which processes piplin | =?Utf-8?B?QW5kcmV3IFNhdmlueWto?= | PowerShell | 2 | 08-08-2006 04:17 PM |