Not just files and folders: introducing PSDrives in VB.NET

Encoder Data Matrix in VB.NET Not just files and folders: introducing PSDrives

Not just files and folders: introducing PSDrives
Painting Data Matrix ECC200 In Visual Basic .NET
Using Barcode creation for .NET framework Control to generate, create ECC200 image in .NET framework applications.
www.OnBarcode.com
Data Matrix 2d Barcode Decoder In Visual Basic .NET
Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
PowerShell
2D Creator In VB.NET
Using Barcode creator for .NET Control to generate, create Matrix 2D Barcode image in .NET framework applications.
www.OnBarcode.com
Print QR In VB.NET
Using Barcode encoder for VS .NET Control to generate, create QR Code 2d barcode image in .NET applications.
www.OnBarcode.com
PSDrive providers
DataMatrix Generation In Visual Basic .NET
Using Barcode encoder for VS .NET Control to generate, create Data Matrix image in VS .NET applications.
www.OnBarcode.com
Drawing Barcode In VB.NET
Using Barcode generator for Visual Studio .NET Control to generate, create Barcode image in .NET applications.
www.OnBarcode.com
FileSystem
1D Creator In VB.NET
Using Barcode generation for .NET framework Control to generate, create Linear image in Visual Studio .NET applications.
www.OnBarcode.com
Encode EAN / UCC - 8 In Visual Basic .NET
Using Barcode creation for VS .NET Control to generate, create UPC - 8 image in Visual Studio .NET applications.
www.OnBarcode.com
Registry
Data Matrix 2d Barcode Creator In Objective-C
Using Barcode drawer for iPad Control to generate, create ECC200 image in iPad applications.
www.OnBarcode.com
Painting Data Matrix 2d Barcode In Java
Using Barcode creator for Java Control to generate, create ECC200 image in Java applications.
www.OnBarcode.com
Etc.
EAN / UCC - 14 Maker In None
Using Barcode generation for Software Control to generate, create EAN / UCC - 13 image in Software applications.
www.OnBarcode.com
Scan Barcode In Visual Basic .NET
Using Barcode decoder for .NET framework Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
Storage systems
Barcode Generator In .NET
Using Barcode creator for ASP.NET Control to generate, create Barcode image in ASP.NET applications.
www.OnBarcode.com
Encoding EAN-13 In None
Using Barcode creator for Online Control to generate, create GTIN - 13 image in Online applications.
www.OnBarcode.com
HKCU
Drawing Code 39 In None
Using Barcode creation for Software Control to generate, create Code 39 image in Software applications.
www.OnBarcode.com
Generate DataMatrix In Visual Studio .NET
Using Barcode generation for .NET framework Control to generate, create Data Matrix ECC200 image in VS .NET applications.
www.OnBarcode.com
HKLM
Making USS Code 39 In None
Using Barcode drawer for Font Control to generate, create Code39 image in Font applications.
www.OnBarcode.com
USS-128 Encoder In Objective-C
Using Barcode generation for iPad Control to generate, create EAN 128 image in iPad applications.
www.OnBarcode.com
Figure 2.2 PSDrive providers adapt different forms of storage so they look like disk drives within PowerShell
Encoding Code 39 Extended In Visual C#.NET
Using Barcode generation for .NET Control to generate, create USS Code 39 image in Visual Studio .NET applications.
www.OnBarcode.com
Creating Code39 In None
Using Barcode maker for Microsoft Word Control to generate, create ANSI/AIM Code 39 image in Office Word applications.
www.OnBarcode.com
There are a few fun facts about PSDrives that you should keep in mind:
The shell always starts with the same PSDrives mapped. You can run the command Get-PSDrive to see them. You ll see one for the HKEY_CURRENT_USER (HKCU) and HKEY_LOCAL_MACHINE (HKLM) registry hives, one for each local disk, one for environment variables, and one each for PowerShell s function, variable, and alias storage (which we re not going to talk about right now). You can map new drives by using the New-PSDrive command. Don t bother doing so now, because it s something you ll practice a bit later. Keep in mind that these are PowerShell drives, so you won t see them in Explorer. They only exist within the shell, and whatever you map will unmap automatically when you close the shell. You ll learn how to overcome that shortcoming near the end of the book. Unlike the old MS-DOS style drive names that were limited to a single letter, PSDrives can have longer names, such as HKCU: and HKLM:. So when you map drives, take the opportunity to make their names more meaningful, like DEMO: or USER: or FILES: rather than X:, Y:, and Z:. If you decide to map a new drive using New-PSDrive, you ll have to specify a name for the drive (without the colon it ll just be DEMO or USER or FILES or whatever), the PSDrive provider that will handle the mapping (such as FileSystem), and the source for the mapping (which might be a UNC). For example,
New-PSDrive -name DEMO -psprovider FileSystem -root \\Server\Share\Folder
TRY IT NOW One thing I found confusing at first was when I was supposed to
add the colon and when I shouldn t. Try running cd hklm and see what happens; then run cd hklm: and see the difference. Whenever you re referring to a drive as part of an action like changing to it you ll add the colon to the end of the drive s name. Spend a few minutes familiarizing yourself with the various default PSDrives. Remember, you can switch to any one of them by using Cd and the drive name, such as Cd Env: or Cd C:. Make sure you can get a directory listing in a variety of drives, and
Running commands
spend a few minutes poking around the Variable: and Env: drives to see what information you find. PSDrives demonstrate an important design concept behind PowerShell itself: it enables you to leverage existing skills in as many places as possible. For example, rather than learning a whole new set of commands for manipulating the registry, you can use the same commands that you already know from the filesystem. Leveraging existing skills makes you more productive and more effective with less of a learning curve.
Support for external commands
So far, all of the commands you ve run in the shell (at least, the ones I ve suggested that you run) have been built-in commands, which Windows PowerShell calls cmdlets (pronounced command-lets ). More than 200 of those cmdlets come built into PowerShell, and you can add more products like Exchange Server, SharePoint Server, and SQL Server all come with add-ins that each include hundreds of additional cmdlets. But you re not limited to the cmdlets that come with PowerShell you can also use the same external command-line utilities that you have probably been using for years, including Ping, Nslookup, Ipconfig, Net, and so forth. Because these aren t native PowerShell cmdlets, you use them the same way that you always have. PowerShell will launch Cmd.exe behind the scenes, because it knows how to run those external commands, and any results will be displayed within the PowerShell window. Go ahead and try a few old favorites right now. For example, I m often asked how you can use PowerShell to map a regular network drive one that can be seen from within Explorer. I always use Net Use, myself, and it works fine within PowerShell. Try running some external command-line utilities that you ve used before. Do they work the same Do any of them fail
Copyright © OnBarcode.com . All rights reserved.