Home
%3CLINGO-SUB%20id%3D%22lingo-sub-353579%22%20slang%3D%22en-US%22%3EPowerShell%20Basics%3A%20Don't%20Fear%20Hitting%20Enter%20with%20-WhatIf%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-353579%22%20slang%3D%22en-US%22%3E%3CP%3EChances%20are%20you've%20run%20into%20this%20situation.%20You've%20built%20a%20script%2C%20or%20a%20one-liner%2C%20to%20perform%20a%20specific%20task%2C%20but%20you%20don't%20have%20a%20way%20to%20thoroughly%20test%20it%20without%20hitting%20Enter.%20That%20moment%20before%20hitting%20enter%20can%20be%20difficult.%20Knowing%20this%20need%2C%20there%20is%20a%20switch%20available%20with%20many%20PowerShell%20commands%20called%3CCODE%3E-WhatIf%3C%2FCODE%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20%3CCODE%3E-WhatIf%3C%2FCODE%3E%2C%20PowerShell%20will%20run%20your%20command%20in%20its%20entirety%20without%20executing%20the%20actions%20of%20the%20command%20so%20no%20changes%20occur.%20It%20displays%20a%20listing%20of%20actions%20to%20be%20performed%20against%20the%20affected%20objects%20in%20the%20console%20window.%20This%20is%20great%20for%20the%20commands%20that%20do%20not%20display%20any%20output%20when%20executed%2C%20or%20if%20you%20are%20unsure%20of%20the%20overall%20impact%20of%20your%20command.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3EImportant%20Note%3A%20-WhatIf%20is%20only%20available%20on%20commands%20that%20make%20changes%20AND%20when%20it%20has%20been%20implemented%20by%20the%20creator%20of%20the%20commands.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHow%20do%20you%20know%20if%20a%20command%20supports%20%3CCODE%3E-WhatIf%3F%3C%2FCODE%3E%20That's%20pretty%20simple.%20Use%20%3CCODE%3Eget-help%3C%2FCODE%3E%20to%20view%20the%20syntax%20of%20the%20command.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22lang-powershell%22%3E%0A%3CSPAN%20class%3D%22hljs-string%22%3EPS%26gt%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-built_in%22%3Eget-help%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eremove-item%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CPRE%3E%3CCODE%3E%3CSPAN%20class%3D%22hljs-symbol%22%3ENAME%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22hljs-symbol%22%3ERemove%3C%2FSPAN%3E-%3CSPAN%20class%3D%22hljs-symbol%22%3EItem%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22hljs-symbol%22%3ESYNOPSIS%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22hljs-symbol%22%3EDeletes%3C%2FSPAN%3E%20files%20and%20folders.%0A%0A%0A%3CSPAN%20class%3D%22hljs-symbol%22%3ESYNTAX%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22hljs-symbol%22%3ERemove%3C%2FSPAN%3E-%3CSPAN%20class%3D%22hljs-symbol%22%3EItem%3C%2FSPAN%3E%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3EConfirm%3C%2FSPAN%3E%5D%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3ECredential%3C%2FSPAN%3E%20%26lt%3B%3CSPAN%20class%3D%22hljs-symbol%22%3EPSCredential%3C%2FSPAN%3E%26gt%3B%5D%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3EExclude%3C%2FSPAN%3E%20%26lt%3B%3CSPAN%20class%3D%22hljs-symbol%22%3EString%3C%2FSPAN%3E%5B%5D%26gt%3B%5D%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3EFilter%3C%2FSPAN%3E%20%26lt%3B%3CSPAN%20class%3D%22hljs-symbol%22%3EString%3C%2FSPAN%3E%26gt%3B%5D%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3EForce%3C%2FSPAN%3E%5D%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3EInclude%3C%2FSPAN%3E%0A%20%20%20%20%26lt%3B%3CSPAN%20class%3D%22hljs-symbol%22%3EString%3C%2FSPAN%3E%5B%5D%26gt%3B%5D%20-%3CSPAN%20class%3D%22hljs-symbol%22%3ELiteralPath%3C%2FSPAN%3E%20%26lt%3B%3CSPAN%20class%3D%22hljs-symbol%22%3EString%3C%2FSPAN%3E%5B%5D%26gt%3B%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3ERecurse%3C%2FSPAN%3E%5D%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3EStream%3C%2FSPAN%3E%20%26lt%3B%3CSPAN%20class%3D%22hljs-symbol%22%3EString%3C%2FSPAN%3E%5B%5D%26gt%3B%5D%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3EUseTransaction%3C%2FSPAN%3E%5D%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3EWhatIf%3C%2FSPAN%3E%5D%0A%20%20%20%20%5B%26lt%3B%3CSPAN%20class%3D%22hljs-symbol%22%3ECommonParameters%3C%2FSPAN%3E%26gt%3B%5D%0A%0A%20%20%20%20%3CSPAN%20class%3D%22hljs-symbol%22%3ERemove%3C%2FSPAN%3E-%3CSPAN%20class%3D%22hljs-symbol%22%3EItem%3C%2FSPAN%3E%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3EPath%3C%2FSPAN%3E%5D%20%26lt%3B%3CSPAN%20class%3D%22hljs-symbol%22%3EString%3C%2FSPAN%3E%5B%5D%26gt%3B%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3EConfirm%3C%2FSPAN%3E%5D%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3ECredential%3C%2FSPAN%3E%20%26lt%3B%3CSPAN%20class%3D%22hljs-symbol%22%3EPSCredential%3C%2FSPAN%3E%26gt%3B%5D%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3EExclude%3C%2FSPAN%3E%20%26lt%3B%3CSPAN%20class%3D%22hljs-symbol%22%3EString%3C%2FSPAN%3E%5B%5D%26gt%3B%5D%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3EFilter%3C%2FSPAN%3E%20%26lt%3B%3CSPAN%20class%3D%22hljs-symbol%22%3EString%3C%2FSPAN%3E%26gt%3B%5D%0A%20%20%20%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3EForce%3C%2FSPAN%3E%5D%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3EInclude%3C%2FSPAN%3E%20%26lt%3B%3CSPAN%20class%3D%22hljs-symbol%22%3EString%3C%2FSPAN%3E%5B%5D%26gt%3B%5D%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3ERecurse%3C%2FSPAN%3E%5D%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3EStream%3C%2FSPAN%3E%20%26lt%3B%3CSPAN%20class%3D%22hljs-symbol%22%3EString%3C%2FSPAN%3E%5B%5D%26gt%3B%5D%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3EUseTransaction%3C%2FSPAN%3E%5D%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3EWhatIf%3C%2FSPAN%3E%5D%20%5B%26lt%3B%3CSPAN%20class%3D%22hljs-symbol%22%3ECommonParameters%3C%2FSPAN%3E%26gt%3B%5D%0A%0A%20%20%20%20%3CSPAN%20class%3D%22hljs-symbol%22%3ERemove%3C%2FSPAN%3E-%3CSPAN%20class%3D%22hljs-symbol%22%3EItem%3C%2FSPAN%3E%20%5B-%3CSPAN%20class%3D%22hljs-symbol%22%3EStream%3C%2FSPAN%3E%20%3CSTRING%3E%5D%20%5B%26lt%3B%3CSPAN%20class%3D%22hljs-symbol%22%3ECommonParameters%3C%2FSPAN%3E%26gt%3B%5D%0A%3C%2FSTRING%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20you%20can%20see%2C%20%3CCODE%3E%5B-WhatIf%5D%3C%2FCODE%3E%20is%20listed%20in%20the%20syntax%20for%20the%20command.%20Also%20it%20will%20be%20available%20as%20a%20tab-complete%20option%20when%20entering%20the%20command.%20If%20you%20do%20happen%20to%20enter%20it%20with%20a%20command%20that%20doesn't%20support%20it%2C%20you'll%20receive%20the%20following%20error%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22lang-powershell%22%3E%0A%3CSPAN%20class%3D%22hljs-string%22%3EPS%20%3C%2FSPAN%3EC%3A%5C%3CSPAN%20class%3D%22hljs-string%22%3EUsers%5C%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-string%22%3Emibender%26gt%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-built_in%22%3Eget-help%3C%2FSPAN%3E%20-%3CSPAN%20class%3D%22hljs-string%22%3EWhatif%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CPRE%3E%3CCODE%3E%3CSPAN%20class%3D%22hljs-string%22%3EGet-Help%20%3C%2FSPAN%3E%3A%20A%20%3CSPAN%20class%3D%22hljs-string%22%3Eparameter%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-string%22%3Ecannot%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-string%22%3Ebe%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-string%22%3Efound%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-string%22%3Ethat%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-string%22%3Ematches%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-string%22%3Eparameter%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-string%22%3Ename%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-string%22%3E'Whatif'%3C%2FSPAN%3E.%0A%3CSPAN%20class%3D%22hljs-string%22%3EAt%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-string%22%3Eline%3A1%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-string%22%3Echar%3A10%0A%3C%2FSPAN%3E%2B%20%3CSPAN%20class%3D%22hljs-built_in%22%3Eget-help%3C%2FSPAN%3E%20-%3CSPAN%20class%3D%22hljs-string%22%3EWhatif%0A%3C%2FSPAN%3E%2B%20%20%20%20%20%20%20%20%20%20~~~~~~~%0A%20%20%20%20%2B%20%3CSPAN%20class%3D%22hljs-string%22%3ECategoryInfo%20%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%3A%20%3CSPAN%20class%3D%22hljs-string%22%3EInvalidArgument%3A%3C%2FSPAN%3E%20(%3A)%20%5B%3CSPAN%20class%3D%22hljs-string%22%3EGet-Help%5D%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22hljs-string%22%3EParameterBindingException%0A%3C%2FSPAN%3E%20%20%20%20%2B%20%3CSPAN%20class%3D%22hljs-string%22%3EFullyQualifiedErrorId%20%3C%2FSPAN%3E%3A%20%3CSPAN%20class%3D%22hljs-string%22%3ENamedParameterNotFound%2C%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-string%22%3EMicrosoft.%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-string%22%3EPowerShell.%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-string%22%3ECommands.%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-string%22%3EGetHelpCommand%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20let's%20see%20an%20example%20of%20how%20this%20works.%20A%20common%20scenario%20is%20needing%20to%20clean%20up%20a%20file%20share%20by%20file%20type.%20In%20this%20case%2C%20I%20want%20to%20find%20all%20of%20the%20video%20files%20in%20an%20MP4%20format%20and%20remove%20them%20from%20my%20%3CCODE%3Ec%3A%5Crecordings%3C%2FCODE%3E%20directory.%20Here's%20the%20process%20you%20would%20run%20through%3A%3C%2FP%3E%0A%3CP%3EFirst%2C%20let's%20find%20all%20of%20the%20MP4%20files%20with%20%3CCODE%3EGet-ChildItem%3C%2FCODE%3E%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22lang-powershell%22%3E%0APS%26gt%3B%20%3CSPAN%20class%3D%22hljs-keyword%22%3EGet%3C%2FSPAN%3E-ChildItem%20-%3CSPAN%20class%3D%22hljs-keyword%22%3EFile%3C%2FSPAN%3E%20*.MP4%20-Recurse%20-LiteralPath%20%3CSPAN%20class%3D%22hljs-keyword%22%3EC%3C%2FSPAN%3E%3A%5CRecordings%5C%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CPRE%3E%3CCODE%3E%0A%20%20%20%20%3CSPAN%20class%3D%22hljs-attribute%22%3EDirectory%3C%2FSPAN%3E%3A%20C%3A%5CRecordings%5Ccar-Talks%5CAttitude-Control%0A%0A%3CSPAN%20class%3D%22brainfuck%22%3E%3CSPAN%20class%3D%22hljs-comment%22%3EMode%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-comment%22%3ELastWriteTime%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-comment%22%3ELength%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-comment%22%3EName%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-comment%22%3Ea%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-comment%22%3E9%2F7%2F2018%3C%2FSPAN%3E%20%20%20%3CSPAN%20class%3D%22hljs-comment%22%3E3%3A47%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-comment%22%3EPM%3C%2FSPAN%3E%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-comment%22%3E58188931%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-comment%22%3EAttitude%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-comment%22%3EControl%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-string%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-comment%22%3Emp4%3C%2FSPAN%3E%0A%0A%20%20%20%20%3CSPAN%20class%3D%22hljs-comment%22%3EDirectory%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-comment%22%3EC%3A%5CRecordings%5Ccar%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-comment%22%3ETalks%5CPersonal%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-comment%22%3EKanBan%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22hljs-comment%22%3EMode%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-comment%22%3ELastWriteTime%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-comment%22%3ELength%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-comment%22%3EName%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-comment%22%3Ea%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-comment%22%3E10%2F5%2F2018%3C%2FSPAN%3E%20%20%20%3CSPAN%20class%3D%22hljs-comment%22%3E1%3A56%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-comment%22%3EPM%3C%2FSPAN%3E%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-comment%22%3E45875317%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-comment%22%3EPersonal%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-comment%22%3EkanBan%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-string%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-comment%22%3Emp4%3C%2FSPAN%3E%0A%0A%20%20%20%20%3CSPAN%20class%3D%22hljs-comment%22%3EDirectory%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-comment%22%3EC%3A%5CRecordings%5Ccar%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-comment%22%3ETalks%5CRedmond%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-comment%22%3EWeek%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-comment%22%3E1%5CRedmond%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-comment%22%3EWeek%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-comment%22%3E1%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22hljs-comment%22%3EMode%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-comment%22%3ELastWriteTime%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-comment%22%3ELength%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-comment%22%3EName%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-comment%22%3Ea%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-comment%22%3E8%2F3%2F2018%3C%2FSPAN%3E%20%20%20%3CSPAN%20class%3D%22hljs-comment%22%3E9%3A01%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-comment%22%3EAM%3C%2FSPAN%3E%20%20%20%20%20%20%20%3CSPAN%20class%3D%22hljs-comment%22%3E19616170%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-comment%22%3ERedmond%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-comment%22%3EWeek%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-literal%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-comment%22%3E1%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-string%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-comment%22%3Emp4%3C%2FSPAN%3E%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ESo%20that%20shows%20us%20all%20of%20the%20MP4%20files%2C%20but%20I'd%20like%20to%20see%20them%20in%20a%20standard%20tables%20format%20with%20just%20their%20name%20and%20directory%20location%20and%20not%20separated%20by%20directory.%20To%20do%20that%2C%20we%20use%20%3CCODE%3ESelect-Object%3C%2FCODE%3E%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22lang-powershell%22%3E%0APS%26gt%3B%20Get-ChildItem%20-File%20*.MP4%20-Recurse%20-LiteralPath%20C%3A%3CSPAN%20class%3D%22hljs-symbol%22%3E%5CR%3C%2FSPAN%3Eecordings%3CSPAN%20class%3D%22hljs-symbol%22%3E%5C%20%3C%2FSPAN%3E%7C%20Select-Object%20Name%2CDirectory%0A%0AName%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Directory%0A----%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20---------%0AAttitude-Control.mp4%20%20%20%20%20%20%20%20%20C%3A%3CSPAN%20class%3D%22hljs-symbol%22%3E%5CR%3C%2FSPAN%3Eecordings%3CSPAN%20class%3D%22hljs-symbol%22%3E%5Cc%3C%2FSPAN%3Ear-Talks%3CSPAN%20class%3D%22hljs-symbol%22%3E%5CA%3C%2FSPAN%3Ettitude-Control%0APersonal-kanBan.mp4%20%20%20%20%20%20%20%20%20%20C%3A%3CSPAN%20class%3D%22hljs-symbol%22%3E%5CR%3C%2FSPAN%3Eecordings%3CSPAN%20class%3D%22hljs-symbol%22%3E%5Cc%3C%2FSPAN%3Ear-Talks%3CSPAN%20class%3D%22hljs-symbol%22%3E%5CP%3C%2FSPAN%3Eersonal-KanBan%0ARedmond-Week-1.mp4%20%20%20%20%20%20%20%20%20%20%20C%3A%3CSPAN%20class%3D%22hljs-symbol%22%3E%5CR%3C%2FSPAN%3Eecordings%3CSPAN%20class%3D%22hljs-symbol%22%3E%5Cc%3C%2FSPAN%3Ear-Talks%3CSPAN%20class%3D%22hljs-symbol%22%3E%5CR%3C%2FSPAN%3Eedmond-Week-1%3CSPAN%20class%3D%22hljs-symbol%22%3E%5CR%3C%2FSPAN%3Eedmond-Week-1%0ASoundTest1.mp4%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20C%3A%3CSPAN%20class%3D%22hljs-symbol%22%3E%5CR%3C%2FSPAN%3Eecordings%3CSPAN%20class%3D%22hljs-symbol%22%3E%5Cc%3C%2FSPAN%3Ear-Talks%3CSPAN%20class%3D%22hljs-symbol%22%3E%5CS%3C%2FSPAN%3Eoundtest%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EThat%20looks%20better.%20What%20I%20did%20was%20use%20the%20pipeline%20and%20%3CCODE%3Eselect-object%3C%2FCODE%3E%20to%20choose%20just%20the%20properties%20I%20wanted%20from%20the%20objects%20output%20from%20the%20initial%20command.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAfter%20I've%20reviewed%20the%20list%2C%20I%20think%20that%20it%20includes%20all%20the%20items%20I%20want%20to%20remove.%20But%20being%20paranoid%2C%20I'd%20really%20like%20to%20know%20that%20it%20is%20going%20to%20remove%20just%20those%20files%20in%20a%20specific%20directory%2C%20and%20not%20all%20the%20files.%20That's%20where%20%3CCODE%3E-WhatIf%3C%2FCODE%3E%20comes%20in%20with%20the%20%3CCODE%3Eremove-item%3C%2FCODE%3E%20command%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22lang-powershell%22%3E%0APS%26gt%3B%20%3CSPAN%20class%3D%22hljs-keyword%22%3EGet%3C%2FSPAN%3E-ChildItem%20-%3CSPAN%20class%3D%22hljs-keyword%22%3EFile%3C%2FSPAN%3E%20*.MP4%20-Recurse%20-LiteralPath%20%3CSPAN%20class%3D%22hljs-keyword%22%3EC%3C%2FSPAN%3E%3A%5CRecordings%5C%20%7C%20%3CSPAN%20class%3D%22hljs-keyword%22%3ERemove%3C%2FSPAN%3E-%3CSPAN%20class%3D%22hljs-keyword%22%3EItem%3C%2FSPAN%3E%20-WhatIf%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CPRE%3E%3CCODE%3E%0AWhat%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eif%3C%2FSPAN%3E%3A%20Performing%20%3CSPAN%20class%3D%22hljs-keyword%22%3Ethe%3C%2FSPAN%3E%20operation%20%3CSPAN%20class%3D%22hljs-string%22%3E%22Remove%20File%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eon%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-title%22%3Etarget%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%22C%3A%5CRecordings%5Ccar-Talks%5CAttitude-Control%5CAttitude-Control.mp4%22%3C%2FSPAN%3E.%0AWhat%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eif%3C%2FSPAN%3E%3A%20Performing%20%3CSPAN%20class%3D%22hljs-keyword%22%3Ethe%3C%2FSPAN%3E%20operation%20%3CSPAN%20class%3D%22hljs-string%22%3E%22Remove%20File%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eon%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-title%22%3Etarget%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%22C%3A%5CRecordings%5Ccar-Talks%5CPersonal-KanBan%5CPersonal-kanBan.mp4%22%3C%2FSPAN%3E.%0AWhat%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eif%3C%2FSPAN%3E%3A%20Performing%20%3CSPAN%20class%3D%22hljs-keyword%22%3Ethe%3C%2FSPAN%3E%20operation%20%3CSPAN%20class%3D%22hljs-string%22%3E%22Remove%20File%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eon%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-title%22%3Etarget%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%22C%3A%5CRecordings%5Ccar-Talks%5CRedmond-Week-1%5CRedmond-Week-1%5CRedmond-Week-1.mp4%22%3C%2FSPAN%3E.%0AWhat%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eif%3C%2FSPAN%3E%3A%20Performing%20%3CSPAN%20class%3D%22hljs-keyword%22%3Ethe%3C%2FSPAN%3E%20operation%20%3CSPAN%20class%3D%22hljs-string%22%3E%22Remove%20File%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eon%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-title%22%3Etarget%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%22C%3A%5CRecordings%5Ccar-Talks%5CSoundtest%5CSoundTest1.mp4%22%3C%2FSPAN%3E.%0AWhat%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eif%3C%2FSPAN%3E%3A%20Performing%20%3CSPAN%20class%3D%22hljs-keyword%22%3Ethe%3C%2FSPAN%3E%20operation%20%3CSPAN%20class%3D%22hljs-string%22%3E%22Remove%20File%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eon%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-title%22%3Etarget%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%22C%3A%5CRecordings%5CMicrosoft%5CContent-Development-AMA%5CContent-Development-AMA.mp4%22%3C%2FSPAN%3E.%0AWhat%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eif%3C%2FSPAN%3E%3A%20Performing%20%3CSPAN%20class%3D%22hljs-keyword%22%3Ethe%3C%2FSPAN%3E%20operation%20%3CSPAN%20class%3D%22hljs-string%22%3E%22Remove%20File%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eon%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-title%22%3Etarget%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%22C%3A%5CRecordings%5CMicrosoft%5CMITT%5CHYB10%5CHYB10-Demos-DryRun1-0.mp4%22%3C%2FSPAN%3E.%0AWhat%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eif%3C%2FSPAN%3E%3A%20Performing%20%3CSPAN%20class%3D%22hljs-keyword%22%3Ethe%3C%2FSPAN%3E%20operation%20%3CSPAN%20class%3D%22hljs-string%22%3E%22Remove%20File%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eon%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-title%22%3Etarget%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%22C%3A%5CRecordings%5CMicrosoft%5CMITT%5CHYB10%5CHYB10-Demos-DryRun1-1.mp4%22%3C%2FSPAN%3E.%0AWhat%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eif%3C%2FSPAN%3E%3A%20Performing%20%3CSPAN%20class%3D%22hljs-keyword%22%3Ethe%3C%2FSPAN%3E%20operation%20%3CSPAN%20class%3D%22hljs-string%22%3E%22Remove%20File%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eon%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-title%22%3Etarget%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%22C%3A%5CRecordings%5CMicrosoft%5CMITT%5CHYB10%5CHYB10-Demos-DryRun1-2.mp4%22%3C%2FSPAN%3E.%0AWhat%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eif%3C%2FSPAN%3E%3A%20Performing%20%3CSPAN%20class%3D%22hljs-keyword%22%3Ethe%3C%2FSPAN%3E%20operation%20%3CSPAN%20class%3D%22hljs-string%22%3E%22Remove%20File%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eon%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-title%22%3Etarget%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%22C%3A%5CRecordings%5CMicrosoft%5CMITT%5CHYB10%5CHYB10-Demos-DryRun1-3.mp4%22%3C%2FSPAN%3E.%0AWhat%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eif%3C%2FSPAN%3E%3A%20Performing%20%3CSPAN%20class%3D%22hljs-keyword%22%3Ethe%3C%2FSPAN%3E%20operation%20%3CSPAN%20class%3D%22hljs-string%22%3E%22Remove%20File%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eon%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-title%22%3Etarget%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%22C%3A%5CRecordings%5CMicrosoft%5CMITT%5CHYB10%5CDryRuns%5CHYB10-Dress-Run-GSL-01.mp4%22%3C%2FSPAN%3E.%0AWhat%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eif%3C%2FSPAN%3E%3A%20Performing%20%3CSPAN%20class%3D%22hljs-keyword%22%3Ethe%3C%2FSPAN%3E%20operation%20%3CSPAN%20class%3D%22hljs-string%22%3E%22Remove%20File%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eon%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-title%22%3Etarget%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%22C%3A%5CRecordings%5CMicrosoft%5CMITT%5CHYB10%5CDryRuns%5CHYB10-DryRun-01.mp4%22%3C%2FSPAN%3E.%0AWhat%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eif%3C%2FSPAN%3E%3A%20Performing%20%3CSPAN%20class%3D%22hljs-keyword%22%3Ethe%3C%2FSPAN%3E%20operation%20%3CSPAN%20class%3D%22hljs-string%22%3E%22Remove%20File%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eon%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-title%22%3Etarget%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%22C%3A%5CRecordings%5CMicrosoft%5CMITT%5CHYB20%5CHYB20-Demo-SecureScore.mp4%22%3C%2FSPAN%3E.%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EBased%20on%20the%20output%2C%20I've%20verified%20that%20on%20the%20MP4%20files%20in%20the%20c%3A%5Crecordings%20directory%20are%20being%20removed.%20Now%20I%20can%20go%20back%20to%20my%20command%20and%20execute%20it%20by%20removing%20the%20%3CCODE%3E-WhatIf%3C%2FCODE%3E%20switch.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%2C%20let's%20say%20it's%202am%20in%20your%20time%20zone%2C%20and%20you%20need%20to%20perform%20multiple%20tasks%20through%20the%20PowerShell%20Console.%20If%20you%20are%20like%20me%2C%202am%20is%20not%20my%20'peak%20productivity'%20hour%20so%20making%20mistakes%2C%20like%20forgetting%20the%20%3CCODE%3E-WhatIf%3C%2FCODE%3E%20switch%2C%20could%20be%20dangerous.%20For%20those%20instances%2C%20you%20can%20modify%20the%20%24WhatIfPreference%20variable%20in%20your%20console%20like%20this%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22lang-powershell%22%3E%0APS%26gt%3B%20%24whatifpreference%0A%3CSPAN%20class%3D%22hljs-keyword%22%3EFalse%3C%2FSPAN%3E%0APS%26gt%3B%20%24whatifpreference%20%3D%20%3CSPAN%20class%3D%22hljs-string%22%3E'True'%3C%2FSPAN%3E%0APS%26gt%3B%20%24whatifpreference%0A%3CSPAN%20class%3D%22hljs-keyword%22%3ETrue%3C%2FSPAN%3E%0APS%26gt%3B%20%3CSPAN%20class%3D%22hljs-keyword%22%3EGet%3C%2FSPAN%3E-ChildItem%20-%3CSPAN%20class%3D%22hljs-keyword%22%3EFile%3C%2FSPAN%3E%20*.MP4%20-Recurse%20-LiteralPath%20%3CSPAN%20class%3D%22hljs-keyword%22%3EC%3C%2FSPAN%3E%3A%5CRecordings%5C%20%7C%20%3CSPAN%20class%3D%22hljs-keyword%22%3ERemove%3C%2FSPAN%3E-%3CSPAN%20class%3D%22hljs-keyword%22%3EItem%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CPRE%3E%3CCODE%3E%0AWhat%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eif%3C%2FSPAN%3E%3A%20Performing%20%3CSPAN%20class%3D%22hljs-keyword%22%3Ethe%3C%2FSPAN%3E%20operation%20%3CSPAN%20class%3D%22hljs-string%22%3E%22Remove%20File%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eon%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-title%22%3Etarget%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%22C%3A%5CRecordings%5Ccar-Talks%5CAttitude-Control%5CAttitude-Control.mp4%22%3C%2FSPAN%3E.%0AWhat%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eif%3C%2FSPAN%3E%3A%20Performing%20%3CSPAN%20class%3D%22hljs-keyword%22%3Ethe%3C%2FSPAN%3E%20operation%20%3CSPAN%20class%3D%22hljs-string%22%3E%22Remove%20File%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eon%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-title%22%3Etarget%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%22C%3A%5CRecordings%5Ccar-Talks%5CPersonal-KanBan%5CPersonal-kanBan.mp4%22%3C%2FSPAN%3E.%0AWhat%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eif%3C%2FSPAN%3E%3A%20Performing%20%3CSPAN%20class%3D%22hljs-keyword%22%3Ethe%3C%2FSPAN%3E%20operation%20%3CSPAN%20class%3D%22hljs-string%22%3E%22Remove%20File%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eon%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-title%22%3Etarget%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%22C%3A%5CRecordings%5Ccar-Talks%5CRedmond-Week-1%5CRedmond-Week-1%5CRedmond-Week-1.mp4%22%3C%2FSPAN%3E.%0AWhat%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eif%3C%2FSPAN%3E%3A%20Performing%20%3CSPAN%20class%3D%22hljs-keyword%22%3Ethe%3C%2FSPAN%3E%20operation%20%3CSPAN%20class%3D%22hljs-string%22%3E%22Remove%20File%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eon%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-title%22%3Etarget%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%22C%3A%5CRecordings%5Ccar-Talks%5CSoundtest%5CSoundTest1.mp4%22%3C%2FSPAN%3E.%0AWhat%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eif%3C%2FSPAN%3E%3A%20Performing%20%3CSPAN%20class%3D%22hljs-keyword%22%3Ethe%3C%2FSPAN%3E%20operation%20%3CSPAN%20class%3D%22hljs-string%22%3E%22Remove%20File%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-keyword%22%3Eon%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-title%22%3Etarget%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%22C%3A%5CRecordings%5CMicrosoft%5CContent-Development-AMA%5CContent-Development-AMA.mp4%22%3C%2FSPAN%3E.%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20the%20command%20to%20remove%20all%20the%20files%20is%20run%20and%20I%20do%20not%20include%20-whatif%20since%20it's%202am%2C%20it%20defaults%20to%20running%20ALL%20commands%20with%20%3CCODE%3E-WhatIf%3C%2FCODE%3E.%20Now%20if%20you%20actually%20want%20to%20run%20the%20command%20and%20remove%20the%20files%2C%20you%20add%20the%20%3CCODE%3E-WhatIf%3C%2FCODE%3E%20switch%20parameter%20and%20specify%20%3CCODE%3E%3A%24false%3C%2FCODE%3E%20like%20this%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22lang-powershell%22%3E%0APS%26gt%3B%20%3CSPAN%20class%3D%22hljs-keyword%22%3EGet%3C%2FSPAN%3E-ChildItem%20-%3CSPAN%20class%3D%22hljs-keyword%22%3EFile%3C%2FSPAN%3E%20*.MP4%20-LiteralPath%20%3CSPAN%20class%3D%22hljs-keyword%22%3EC%3C%2FSPAN%3E%3A%5CRecordings%5CTest-Recording%5C%20%7C%20%3CSPAN%20class%3D%22hljs-keyword%22%3ERemove%3C%2FSPAN%3E-%3CSPAN%20class%3D%22hljs-keyword%22%3EItem%3C%2FSPAN%3E%20-WhatIf%3A%24false%20-%3CSPAN%20class%3D%22hljs-keyword%22%3EVerbose%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CPRE%3E%3CCODE%3E%0AVERBOSE%3A%20Performing%20the%20operation%20%22Remove%20File%22%20on%20target%20%22C%3A%3CSPAN%20class%3D%22hljs-tag%22%3E%5C%3CSPAN%20class%3D%22hljs-name%22%3ERecordings%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-tag%22%3E%5C%3CSPAN%20class%3D%22hljs-name%22%3ETest%3C%2FSPAN%3E%3C%2FSPAN%3E-Recording%3CSPAN%20class%3D%22hljs-tag%22%3E%5C%3CSPAN%20class%3D%22hljs-name%22%3ETest%3C%2FSPAN%3E%3C%2FSPAN%3E-Take-SA.mp4%22.%0A%0A%60%60%60powershell%0A%0APS%20CMD%26gt%3B%20Get-ChildItem%20-File%20*.MP4%20-LiteralPath%20C%3A%3CSPAN%20class%3D%22hljs-tag%22%3E%5C%3CSPAN%20class%3D%22hljs-name%22%3ERecordings%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-tag%22%3E%5C%3CSPAN%20class%3D%22hljs-name%22%3ETest%3C%2FSPAN%3E%3C%2FSPAN%3E-Recording%3CSPAN%20class%3D%22hljs-tag%22%3E%5C%0A%3C%2FSPAN%3EPS%20CMD%26gt%3B%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EOne%20thing%20to%20remember%20with%20this%20and%20other%20preference%20variables%20you%20define%20in%20the%20console%20is%20they%20only%20maintain%20the%20setting%20in%20your%20current%20shell.%20When%20you%20close%20and%20re-open%20PowerShell%2C%20the%20preference%20will%20reset.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnother%20thing%20is%20a%20%3CSTRONG%3Eword%20of%20caution%3C%2FSTRONG%3E%20on%20using%20%3CCODE%3E-WhatIf%3C%2FCODE%3E.%20Because%20it%20is%20functionality%20that%20is%20added%20into%20commands%2C%20the%20implementer%20may%20not%20implement%20it%20properly%20or%20not%20at%20all.%20I've%20never%20run%20into%20issues%20with%20Microsoft-built%20commands%20using%20%3CCODE%3E-WhatIf%3C%2FCODE%3E%20like%20Microsoft%20Exchange%2C%20Active%20Directory%2C%20and%20many%20of%20the%20built-in%20commands%20I%20use%20below.%20However%2C%20I%20cannot%20speak%20for%20code%20samples%20you%20may%20find%20in%20the%20wild%2C%20or%20the%20full%20gamet%20of%20Micrsoft%20product%20team-produced%20commands.%20To%20be%20safe%2C%20you%20should%20test%20-whatif%20against%20a%20smaller%20pool%20of%20targets%20vs.%20trying%20to%20modify%20every%20Exchange%20mailbox%3C%2FP%3E%0A%3CP%3Ein%20your%20organization.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%20the%20next%20time%20you%20need%20to%20perform%20some%20PowerShell%20tasks%2C%20add%20-whatif%20before%20you%20execute%2C%20and%20stop%20fearing%20the%20%3CCODE%3EEnter%3C%2FCODE%3E%20key.%3C%2FP%3E%0A%3CP%3EFor%20more%20information%20on%20the%20commands%20used%20in%20this%20post%2C%20click%20on%20the%20links%20below%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fmicrosoft.powershell.management%2Fget-childitem%3FWT_id.md%3Ditopstalk-blog-mibender%26amp%3Bview%3Dpowershell-6%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGet-ChildItem%3C%2FA%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2FMicrosoft.PowerShell.Management%2FRemove-Item%3FWT_id.md%3Ditopstalk-blog-mibender%26amp%3Bview%3Dpowershell-6%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ERemove-Item%3C%2FA%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2FMicrosoft.PowerShell.Utility%2FSelect-Object%3FWT_id.md%3Ditopstalk-blog-mibender%26amp%3Bview%3Dpowershell-6%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESelect-Object%3C%2FA%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fmicrosoft.powershell.core%2Fabout%2Fabout_preference_variables%3FWT_id.md%3Ditopstalk-blog-mibender%26amp%3Bview%3Dpowershell-6%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E_about_preference_variables%3C%2FA%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EWondering%20what%20commands%20actually%20work%20with%20-WhatIf%3F%20Check%20out%20%3CA%20href%3D%22https%3A%2F%2Fblogs.msmvps.com%2Frichardsiddaway%2F2014%2F08%2F12%2Fcan-it-whatif%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%20blog%3C%2FA%3E%20by%20PowerShell%20MVP%20Richard%20Siddaway%20for%20more%20information.%3C%2FP%3E%0A%3CP%3EFor%20more%20information%20on%20PowerShell%2C%20check%20out%20the%20docs%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2F%3FWT_id.md%3Ditopstalk-blog-mibender%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-353579%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20style%3D%22background-color%3A%20%23ffffff%3B%20box-sizing%3A%20border-box%3B%20color%3A%20%23333333%3B%20cursor%3A%20text%3B%20display%3A%20inline%3B%20float%3A%20none%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3EChances%20are%20you've%20run%20into%20this%20situation.%20You've%20built%20a%20script%2C%20or%20a%20one-liner%2C%20to%20perform%20a%20specific%20task%2C%20but%20you%20don't%20have%20a%20way%20to%20thoroughly%20test%20it%20without%20hitting%20Enter.%20That%20moment%20before%20hitting%20enter%20can%20be%20difficult.%20Knowing%20this%20need%2C%20there%20is%20a%20switch%20available%20with%20many%20PowerShell%20commands%20called%20%3C%2FSPAN%3E%3CCODE%20style%3D%22background-color%3A%20%23f9f2f4%3B%20border-bottom-left-radius%3A%204px%3B%20border-bottom-right-radius%3A%204px%3B%20border-top-left-radius%3A%204px%3B%20border-top-right-radius%3A%204px%3B%20box-sizing%3A%20border-box%3B%20color%3A%20%23c7254e%3B%20font-family%3A%20Menlo%2CMonaco%2CConsolas%2C%26amp%3Bquot%3B%20courier%20new%26amp%3Bquot%3B%2Cmonospace%3B%20font-size%3A%2090%25%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%20padding%3A%202px%204px%202px%204px%3B%22%3E-WhatIf%3C%2FCODE%3E%3CSPAN%20style%3D%22background-color%3A%20%23ffffff%3B%20box-sizing%3A%20border-box%3B%20color%3A%20%23333333%3B%20cursor%3A%20text%3B%20display%3A%20inline%3B%20float%3A%20none%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3E.%3C%2FSPAN%3E%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20%23ffffff%3B%20color%3A%20%23333333%3B%20cursor%3A%20text%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20%23ffffff%3B%20color%3A%20%23333333%3B%20cursor%3A%20text%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F64467i59DAE518FEDCC930%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22PowerShell_Basics.jpg%22%20title%3D%22PowerShell_Basics.jpg%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EPowerShell%20Basics%20Series%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20right%3B%22%3E%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20%23ffffff%3B%20color%3A%20%23333333%3B%20cursor%3A%20text%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F83618iC8F6CEAD6DCAC41B%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22PowerShell-Console-WhatIf.png%22%20title%3D%22PowerShell-Console-WhatIf.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-353579%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-376820%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20Basics%3A%20Don't%20Fear%20Hitting%20Enter%20with%20-WhatIf%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-376820%22%20slang%3D%22en-US%22%3E%3CP%3EJust%20came%20through%20another%20one%3A%3C%2FP%3E%3CPRE%3ESet-Volume%20-DriveLetter%20C%20-NewFileSystemLabel%20SYSTEM%20-WhatIf%3C%2FPRE%3E%3CP%3EThere%20is%20nothing%20dangerous%20here%2C%20but%20the%20the%20fact%20is%20that%20the%20%3CSTRONG%3EWhatIf%3C%2FSTRONG%3E%20parameter%20is%20just%20ignored.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-355038%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20Basics%3A%20Don't%20Fear%20Hitting%20Enter%20with%20-WhatIf%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-355038%22%20slang%3D%22en-US%22%3E%3CP%3EThat's%20what%20I've%20been%20hearing.%20If%20you%20have%20specific%20cmdlets%20that%20you%20know%20don't%20work%2C%20let%20me%20know.%20I'm%20happy%20to%20see%20if%20I%20can%20get%20them%20fixed.%20Feel%20free%20to%20comment%20here%20or%20email%20me%20at%20michael.bender%40microsoft.com.%20Thanks!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-355028%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20Basics%3A%20Don't%20Fear%20Hitting%20Enter%20with%20-WhatIf%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-355028%22%20slang%3D%22en-US%22%3EThere%20are%20several%20MICROSOFT%20cmdlets%20that%20say%20they%20support%20-WhatIf%20Then%20go%20ahead%20and%20perform%20the%20action%20regardless%20of%20-WhatIf%20anyway%20but%20-WhatIf%20is%20amazing%20when%20it's%20honoured%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-354951%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20Basics%3A%20Don't%20Fear%20Hitting%20Enter%20with%20-WhatIf%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-354951%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20are%20right%20about%20your%20warning.%20There%20is%20a%20know%20case%20where%20the%20WhatIf%20parameter%20doesn't%20work.%20Unfortunately%2C%20I%20discovered%20it%20a%20bit%20late...%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwindowsserver.uservoice.com%2Fforums%2F304621-active-directory%2Fsuggestions%2F10844361-set-adaccountpassword-whatif-does-not-work%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwindowsserver.uservoice.com%2Fforums%2F304621-active-directory%2Fsuggestions%2F10844361-set-adaccountpassword-whatif-does-not-work%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-432361%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20Basics%3A%20Don't%20Fear%20Hitting%20Enter%20with%20-WhatIf%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-432361%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20for%20the%20heads%20up%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F63478%22%20target%3D%22_blank%22%3E%40Luc%20FULLENWARTH%3C%2FA%3E%20!%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

Chances are you've run into this situation. You've built a script, or a one-liner, to perform a specific task, but you don't have a way to thoroughly test it without hitting Enter. That moment before hitting enter can be difficult. Knowing this need, there is a switch available with many PowerShell commands called -WhatIf.

 

With -WhatIf, PowerShell will run your command in its entirety without executing the actions of the command so no changes occur. It displays a listing of actions to be performed against the affected objects in the console window. This is great for the commands that do not display any output when executed, or if you are unsure of the overall impact of your command.

 

Important Note: -WhatIf is only available on commands that make changes AND when it has been implemented by the creator of the commands.

 

How do you know if a command supports -WhatIf? That's pretty simple. Use get-help to view the syntax of the command.


PS> get-help remove-item
NAME
    Remove-Item

SYNOPSIS
    Deletes files and folders.


SYNTAX
    Remove-Item [-Confirm] [-Credential <PSCredential>] [-Exclude <String[]>] [-Filter <String>] [-Force] [-Include
    <String[]>] -LiteralPath <String[]> [-Recurse] [-Stream <String[]>] [-UseTransaction] [-WhatIf]
    [<CommonParameters>]

    Remove-Item [-Path] <String[]> [-Confirm] [-Credential <PSCredential>] [-Exclude <String[]>] [-Filter <String>]
    [-Force] [-Include <String[]>] [-Recurse] [-Stream <String[]>] [-UseTransaction] [-WhatIf] [<CommonParameters>]

    Remove-Item [-Stream <string>] [<CommonParameters>]

 

As you can see, [-WhatIf] is listed in the syntax for the command. Also it will be available as a tab-complete option when entering the command. If you do happen to enter it with a command that doesn't support it, you'll receive the following error:


PS C:\Users\mibender> get-help -Whatif
Get-Help : A parameter cannot be found that matches parameter name 'Whatif'.
At line:1 char:10
+ get-help -Whatif
+          ~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-Help], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetHelpCommand

 

Now let's see an example of how this works. A common scenario is needing to clean up a file share by file type. In this case, I want to find all of the video files in an MP4 format and remove them from my c:\recordings directory. Here's the process you would run through:

First, let's find all of the MP4 files with Get-ChildItem:


PS> Get-ChildItem -File *.MP4 -Recurse -LiteralPath C:\Recordings\

    Directory: C:\Recordings\car-Talks\Attitude-Control

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----         9/7/2018   3:47 PM       58188931 Attitude-Control.mp4

    Directory: C:\Recordings\car-Talks\Personal-KanBan

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        10/5/2018   1:56 PM       45875317 Personal-kanBan.mp4

    Directory: C:\Recordings\car-Talks\Redmond-Week-1\Redmond-Week-1

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----         8/3/2018   9:01 AM       19616170 Redmond-Week-1.mp4

So that shows us all of the MP4 files, but I'd like to see them in a standard tables format with just their name and directory location and not separated by directory. To do that, we use Select-Object:


PS> Get-ChildItem -File *.MP4 -Recurse -LiteralPath C:\Recordings\ | Select-Object Name,Directory

Name                         Directory
----                         ---------
Attitude-Control.mp4         C:\Recordings\car-Talks\Attitude-Control
Personal-kanBan.mp4          C:\Recordings\car-Talks\Personal-KanBan
Redmond-Week-1.mp4           C:\Recordings\car-Talks\Redmond-Week-1\Redmond-Week-1
SoundTest1.mp4               C:\Recordings\car-Talks\Soundtest

That looks better. What I did was use the pipeline and select-object to choose just the properties I wanted from the objects output from the initial command.

 

After I've reviewed the list, I think that it includes all the items I want to remove. But being paranoid, I'd really like to know that it is going to remove just those files in a specific directory, and not all the files. That's where -WhatIf comes in with the remove-item command:


PS> Get-ChildItem -File *.MP4 -Recurse -LiteralPath C:\Recordings\ | Remove-Item -WhatIf

What if: Performing the operation "Remove File" on target "C:\Recordings\car-Talks\Attitude-Control\Attitude-Control.mp4".
What if: Performing the operation "Remove File" on target "C:\Recordings\car-Talks\Personal-KanBan\Personal-kanBan.mp4".
What if: Performing the operation "Remove File" on target "C:\Recordings\car-Talks\Redmond-Week-1\Redmond-Week-1\Redmond-Week-1.mp4".
What if: Performing the operation "Remove File" on target "C:\Recordings\car-Talks\Soundtest\SoundTest1.mp4".
What if: Performing the operation "Remove File" on target "C:\Recordings\Microsoft\Content-Development-AMA\Content-Development-AMA.mp4".
What if: Performing the operation "Remove File" on target "C:\Recordings\Microsoft\MITT\HYB10\HYB10-Demos-DryRun1-0.mp4".
What if: Performing the operation "Remove File" on target "C:\Recordings\Microsoft\MITT\HYB10\HYB10-Demos-DryRun1-1.mp4".
What if: Performing the operation "Remove File" on target "C:\Recordings\Microsoft\MITT\HYB10\HYB10-Demos-DryRun1-2.mp4".
What if: Performing the operation "Remove File" on target "C:\Recordings\Microsoft\MITT\HYB10\HYB10-Demos-DryRun1-3.mp4".
What if: Performing the operation "Remove File" on target "C:\Recordings\Microsoft\MITT\HYB10\DryRuns\HYB10-Dress-Run-GSL-01.mp4".
What if: Performing the operation "Remove File" on target "C:\Recordings\Microsoft\MITT\HYB10\DryRuns\HYB10-DryRun-01.mp4".
What if: Performing the operation "Remove File" on target "C:\Recordings\Microsoft\MITT\HYB20\HYB20-Demo-SecureScore.mp4".

Based on the output, I've verified that on the MP4 files in the c:\recordings directory are being removed. Now I can go back to my command and execute it by removing the -WhatIf switch.

 

Now, let's say it's 2am in your time zone, and you need to perform multiple tasks through the PowerShell Console. If you are like me, 2am is not my 'peak productivity' hour so making mistakes, like forgetting the -WhatIf switch, could be dangerous. For those instances, you can modify the $WhatIfPreference variable in your console like this:


PS> $whatifpreference
False
PS> $whatifpreference = 'True'
PS> $whatifpreference
True
PS> Get-ChildItem -File *.MP4 -Recurse -LiteralPath C:\Recordings\ | Remove-Item

What if: Performing the operation "Remove File" on target "C:\Recordings\car-Talks\Attitude-Control\Attitude-Control.mp4".
What if: Performing the operation "Remove File" on target "C:\Recordings\car-Talks\Personal-KanBan\Personal-kanBan.mp4".
What if: Performing the operation "Remove File" on target "C:\Recordings\car-Talks\Redmond-Week-1\Redmond-Week-1\Redmond-Week-1.mp4".
What if: Performing the operation "Remove File" on target "C:\Recordings\car-Talks\Soundtest\SoundTest1.mp4".
What if: Performing the operation "Remove File" on target "C:\Recordings\Microsoft\Content-Development-AMA\Content-Development-AMA.mp4".

 

When the command to remove all the files is run and I do not include -whatif since it's 2am, it defaults to running ALL commands with -WhatIf. Now if you actually want to run the command and remove the files, you add the -WhatIf switch parameter and specify :$false like this:


PS> Get-ChildItem -File *.MP4 -LiteralPath C:\Recordings\Test-Recording\ | Remove-Item -WhatIf:$false -Verbose

VERBOSE: Performing the operation "Remove File" on target "C:\Recordings\Test-Recording\Test-Take-SA.mp4".

```powershell

PS CMD> Get-ChildItem -File *.MP4 -LiteralPath C:\Recordings\Test-Recording\
PS CMD>

One thing to remember with this and other preference variables you define in the console is they only maintain the setting in your current shell. When you close and re-open PowerShell, the preference will reset.

 

Another thing is a word of caution on using -WhatIf. Because it is functionality that is added into commands, the implementer may not implement it properly or not at all. I've never run into issues with Microsoft-built commands using -WhatIf like Microsoft Exchange, Active Directory, and many of the built-in commands I use below. However, I cannot speak for code samples you may find in the wild, or the full gamet of Micrsoft product team-produced commands. To be safe, you should test -whatif against a smaller pool of targets vs. trying to modify every Exchange mailbox

in your organization.

 

So the next time you need to perform some PowerShell tasks, add -whatif before you execute, and stop fearing the Enter key.

For more information on the commands used in this post, click on the links below:

Wondering what commands actually work with -WhatIf? Check out this blog by PowerShell MVP Richard Siddaway for more information.

For more information on PowerShell, check out the docs here

5 Comments
Senior Member

You are right about your warning. There is a know case where the WhatIf parameter doesn't work. Unfortunately, I discovered it a bit late...

https://windowsserver.uservoice.com/forums/304621-active-directory/suggestions/10844361-set-adaccoun...

Occasional Visitor
There are several MICROSOFT cmdlets that say they support -WhatIf Then go ahead and perform the action regardless of -WhatIf anyway but -WhatIf is amazing when it's honoured
Microsoft

That's what I've been hearing. If you have specific cmdlets that you know don't work, let me know. I'm happy to see if I can get them fixed. Feel free to comment here or email me at michael.bender@microsoft.com. Thanks!

 

Senior Member

Just came through another one:

Set-Volume -DriveLetter C -NewFileSystemLabel SYSTEM -WhatIf

There is nothing dangerous here, but the the fact is that the WhatIf parameter is just ignored.

Microsoft

Thanks for the heads up, @Luc FULLENWARTH !