PowerShell's New-Item is a
versatile cmdlet particularly good for creating files and folders.
New-Item typifies PowerShell's simplicity coupled with power, added to
versatility.
Note 1: As usual with my -path examples, I
introduce a variable mainly to remind you to change its value if you
want the script to work on your machine!
Note 2: The -itemType parameter can be abbreviated
to plain -Type. Also "Directory" does not have to be in quotes.
Note 3: If the script succeeds PowerShell gives you
a summary of what the script achieved, however, I still like to open
Windows Explorer to checkout my new folder.
Note 4: If your version of the script fails, start
troubleshooting with value of $Location.
Note 5: That it's a case of New-Item file by name
and -type "file" by nature. By that I mean check your -type (or -itemType)
string value.
SolarWinds Firewall Browser
Here is an utility where you can review firewall settings such as
access control lists (ACL), or troubleshoot problems with network
address translation (NAT).
Other reasons to download this SolarWinds Firewall Browser include
managing requests to change your firewall settings, testing firewall
rules before you go live, and querying settings with the browser's
powerful search options.
Guy Recommends: A Free Trial of the Network Performance Monitor
(NPM)
SolarWinds'
Network Performance Monitor
will help you discover what's happening on your network. This
utility will also guide you through troubleshooting; the dashboard will
indicate whether the root cause is a broken link, faulty equipment or
resource overload.
What I like best is the way NPM suggests solutions to network
problems. Its also has the ability to monitor the health of individual VMware
virtual machines. If you are interested in troubleshooting, and creating
network maps, then I recommend that you try NPM now.
Examining New-Item's parameters is particularly fruitful. It
emphasises the variety of objects that you can create, and how you can
employ parameters to modify the new article and even give it initial
values.
New-Item has an alias of Ni. In addition, Mkdir or Md mimics
New-Item and creates a directory.
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. One obvious
example is that you can abbreviate Format-Table to ft. 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
This reminds me that there is a Remove-Item
cmdlet, which can be useful for removing
your failed experiments, but go carefully, Remove-Item can lead to
disaster, so before use even Gung-ho Guy backs up at least some of the
File structure of registry. PowerShell -Noun or -verb research
always throws up at least one surprise. You could also research
with -Verb New.
Research More 'New' Cmdlets
I was surprised how many cmdlets started with verb 'New', here is the
list which you can obtain with Get-Command -Verb New
Sooner or later everyone needs
new stuff. Whether it's a file, folder or registry key, New-Item can
deliver just the article that you need for your PowerShell project.
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
most useful for PowerShell scripting.
SolarWinds
have produced this
Free WMI Monitor to take the guess work out of which
WMI counters to use for applications like Microsoft Active Directory,
SQL or Exchange Server.