This blog has moved to http://ThePowerShellGuy.com
Greetings /\/\o\/\/
As I was in a small discussion about the use of the -errorAction Switch,
with NotBotherMeWithSpam,
I did think of a very useless and confusing use of it with new-item.
but as I think we where spaming the NG a bit already ;-),
I will post it here (below Sig).
as I type another error on my part came in on the NG,
my use of the stringbuilder class was wrong (I did use it to show where to use [VOID], but as you see below not with the stringbuilder ;-) )
you should use it like this :
$sb = $sb.append("newText")
so that would mean another edit to my script to generate "WMI method call" sample-scripts :
MSH get-WmiMethodHelp (GWM) Update + format tips. (I leave that up to you)
gr /\/\o\/\/
PS don't do this to your users !!MSH>new-item -ea Inquire -type file testing.txt
Confirm
The file 'C:\Documents and Settings\mow\testing.txt' already exists.
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): y
new-item : The file 'C:\Documents and Settings\mow\testing.txt' already exists.
At line:1 char:9
+ new-item <<<< -ea Inquire -type file testing.txt MSH>new-item -ea Inquire -type file testing.txt
Confirm
The file 'C:\Documents and Settings\mow\testing.txt' already exists.
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): h
new-item : Command execution stopped because the user selected the Halt option.
At line:1 char:9
+ new-item <<<< -ea Inquire -type file testing.txt
MSH>