考虑:
PS Y:\> mkdir C:/dog
Directory: C:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 11/7/2013 10:59 PM dog
PS Y:\> mkdir C:/dog
New-Item : Item with specified name C:\dog already exists.
At line:38 char:24
+ $scriptCmd = {& <<<< $wrappedCmd -Type Directory @PSBoundParameters }
+ CategoryInfo : ResourceExists: (C:\dog:String) [New-Item], IOException
+ FullyQualifiedErrorId : DirectoryExist,Microsoft.PowerShell.Commands.NewItemCommand
Run Code Online (Sandbox Code Playgroud)
Kei*_*ill 26
将-Force参数添加到命令中.
Jac*_*kie 14
怎么样
mkdir C:\dog -ErrorAction SilentlyContinue
Run Code Online (Sandbox Code Playgroud)