Warning: I have been unusually cautious on this
page, because if a delete script goes wrong and forces a delete of the wrong
files it could be disastrous. Hundreds of people will succeed no
trouble, but I do worry about that one person who gets the wrong end of
Remove-Item and deletes the wrong files.
Note: There is no PowerShell Delete-Item cmdlet it's Remove-Item
Import users from a spreadsheet. Just provide a list of the
users with their fields in the
top row, and save as .csv file. Then launch this FREE utility and match
your fields with AD's
attributes, click to import the users. Optionally, you can
provide the name of the OU where the new accounts will be born.
There are also two bonus tools in this free download, and all 3 have been approved by Microsoft:
Checking the help file will reveal useful parameters, for instance
-force -exclude. Dare I tell you that there is also -recurse, but
in the case of Remove-Item, use that parameter with the utmost care.
Remove-Item Aliases Del and Erase
Check the aliases with this little script:
# PowerShell Remove-Item Alias Clear-Host Get-Alias
-definition Remove-Item
Note 4: There is no actual PowerShell Delete-Item
cmdlet, however, there is a 'del'
alias.
With Microsoft, there are always at least three ways of doing
everything, what seems like redundancy when you are an expert, seems
like perspective when you are a beginner. As you increase your
range of PowerShell commands, keep an eye out for another
PowerShell Alias, for example gci (Get-Childitem).
Researching Similar PowerShell Cmdlets
# PowerShell Item Cmdlet Research Clear-Host
Get-Command -noun Item
As we know there is a Get-Item and a New-Item cmdlet, but you may not realize there
is a Copy-Item cmdlet. PowerShell -noun or -verb research
always throws up at least one surprise. In this case it's the
absence of a PowerShell Delete-Item cmdlet, use Remove-Item instead.
»
Summary of PowerShell Remove-Item
The syntax for Remove-Item is
straightforward. I urge you to take precautions because if you get the
path wrong, the effect could be devastating, especially if you are gung-ho
with the -force and the -recurse parameter. For this reason I suggest
that you check with Get-Item before you actually use Remove-Item, even then
consider the -whatIf switch if there is any doubt.
If you like this page then please share it with your friends
See more PowerShell examples for syntax constructions
Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.
Windows Management Instrumentation (WMI) is one of the hidden
treasures of Microsoft operating systems.
Fortunately, Solarwinds
have created the
Free WMI Monitor so that you can actually see and understand these gems of
performance information. Take the guess work out of which
WMI counters to use for applications like Microsoft Active Directory,
SQL or Exchange Server.