How to not run second command when first command failed


hi

i've got script 2 commands. how not run second command if first faild?

for example:

move-vmstorage -computername $vmnodename -vmname $vmname -destinationstoragepath $path

remove-item -path $oldpath -recurse -include *.vhd*

how stop running command (avoid) "remove-item -path $oldpath -recurse -include *.vhd*" if first command

"move-vmstorage -computername $vmnodename -vmname $vmname -destinationstoragepath $path" faild (i've got an error)?

so how to change script?

thank mouch help!!!

 


kind regards tomasz

# easiest way

move-vmstorage -computername $vmnodename -vmname $vmname -destinationstoragepath $path
if($?){remove-item -path $oldpath -recurse -include *.vhd}


\_(ツ)_/



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Group Policy Event ID 1058 Error Code 1326 (The user name or password is incorrect)

Suspicious event log Event ID: 4905

DCOM received error "2147746132" from...