Tips, Tricks, and Troubleshooting in .NET framework

Making USS Code 39 in .NET framework Tips, Tricks, and Troubleshooting
10 Tips, Tricks, and Troubleshooting
Code 3 Of 9 Creation In .NET Framework
Using Barcode generator for .NET framework Control to generate, create Code 39 image in .NET applications.
Figure 103 Execution of a script in single steps with con rmation
Reading Code39 In Visual Studio .NET
Using Barcode scanner for .NET Control to read, scan read, scan image in Visual Studio .NET applications.
WARNING When experimenting with Set-TraceSource, you might soon reach the point where you cannot see the real actions because of all those protocols displayed To deactivate the tracing, use Set-TraceSource with the parameter RemoveListener
Printing Bar Code In .NET
Using Barcode maker for Visual Studio .NET Control to generate, create barcode image in .NET framework applications.
Commandlet Extensions
Scan Barcode In Visual Studio .NET
Using Barcode decoder for .NET Control to read, scan read, scan image in .NET framework applications.
WPS does not have a xed set of commandlets Additional commandlets can be added when WPS is started or at any time during its operation Additional commandlets are either implemented as WPS script les, which are added via dot sourcing (see 8, Using Class Libraries ) or via installation of a snap-in (described in the following text)
Code39 Generator In C#.NET
Using Barcode creator for .NET framework Control to generate, create Code 39 image in .NET applications.
Commandlet Extensions
Encode Code-39 In Visual Studio .NET
Using Barcode drawer for ASP.NET Control to generate, create Code 3/9 image in ASP.NET applications.
Adding Snap-Ins
Code 39 Full ASCII Drawer In VB.NET
Using Barcode generator for .NET framework Control to generate, create USS Code 39 image in .NET applications.
Commandlet extensions are delivered in the form of a snap-in DLL They have to be integrated in WPS in two steps: 1 Registering the DLL (alternatively called assembly) that contains the commandlets 2 Loading the snap-in to the WPS console
Drawing Code 128 In Visual Studio .NET
Using Barcode generation for .NET Control to generate, create ANSI/AIM Code 128 image in Visual Studio .NET applications.
10 TIPS, TRICKS, AND TROUBLESHOOTING
Barcode Encoder In .NET
Using Barcode creator for .NET Control to generate, create bar code image in VS .NET applications.
DLL Registration
UCC - 12 Generator In .NET Framework
Using Barcode creator for .NET framework Control to generate, create UPC Symbol image in Visual Studio .NET applications.
Registration of the DLL is performed with the command-line tool installutilexe, which is installed together with the NET Framework You will nd the tool in the installation directory of the NET Framework (usually c:\Windows\Microsoft NET\Framework\v xy\) WPS has implemented this path automatically as a search path for the command When using installutilexe, you must indicate the lename of the extension DLL, including the path (in case the WPS console does not already have this exact path as the current path)
Barcode Encoder In .NET Framework
Using Barcode creation for .NET framework Control to generate, create bar code image in VS .NET applications.
installutilexe G:\PowerShell_Commandlet_Library\PowerShell_Commandletsdll
Uniform Symbology Specification Codabar Creator In .NET Framework
Using Barcode maker for VS .NET Control to generate, create USS Codabar image in .NET framework applications.
Figure 104 shows how the tool displays the successful installation The registration has the effect that the DLL is added to the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ PowerShellSnapIns
DataMatrix Reader In VS .NET
Using Barcode scanner for .NET Control to read, scan read, scan image in .NET applications.
Loading of Snap-Ins to the PowerShell Console
ANSI/AIM Code 39 Drawer In VS .NET
Using Barcode generation for ASP.NET Control to generate, create ANSI/AIM Code 39 image in ASP.NET applications.
To load a snap-in, you must use the commandlet Add-PSSnapin in the WPS console This commandlet needs the name of the snap-in, not the name of the DLL If you do not know the name of a snap-in, see the section Listing Snap-Ins later in this chapter
Scan UCC - 12 In Visual Studio .NET
Using Barcode decoder for .NET framework Control to read, scan read, scan image in .NET applications.
Add-PSSnapin PowerShell_Commandlet_Library
Barcode Printer In VB.NET
Using Barcode printer for .NET Control to generate, create bar code image in .NET framework applications.
10 Tips, Tricks, and Troubleshooting
Barcode Drawer In Visual C#.NET
Using Barcode encoder for VS .NET Control to generate, create bar code image in VS .NET applications.
Figure 104 Output of Installutilexe Whereas registration of a DLL is necessary only once, the WPS console discards a loaded snap-in each time it is terminated If you want WPS to always start with certain extensions, you have two options:
ANSI/AIM Code 39 Generation In Java
Using Barcode printer for Java Control to generate, create USS Code 39 image in Java applications.
Add the relevant Add-PSSnapIn commands in your system-wide or user-speci c pro le le (Pro leps1, see PowerShell Pro les in this chapter and Figure 105) Export a console con guration le with Export-Console (see Figure 106) At rst, however, you have to add the snap-in to the current console, and then you can export this current console This creates an XML le with the lename extension psc1 The PSC le has to be handed to WPS with the command-line parameter PSConsoleFile when it is started
Encode Data Matrix In Visual Basic .NET
Using Barcode generation for Visual Studio .NET Control to generate, create Data Matrix image in .NET applications.
Commandlet Extensions
Print UCC.EAN - 128 In .NET Framework
Using Barcode maker for ASP.NET Control to generate, create EAN / UCC - 14 image in ASP.NET applications.
10 TIPS, TRICKS, AND TROUBLESHOOTING
Figure 105 Loading a snap-in in the pro le le
Figure 106 Exporting a console con guration le The best thing to do is to create a link in your le system with the following destination (see Figure 107):
%SystemRoot%\system32\WindowsPowerShell\v10\powershellexe -PSConsoleFile "G:\Consoles\HolgersConsolepsc1"
10 Tips, Tricks, and Troubleshooting
Figure 107 Creating a link to the WPS console; the link automatically loads a certain console con guration le
Listing Snap-Ins
The commandlet Get-PSSnapIn usually lists only those snap-ins that already have been added to the WPS by using the Add-PSSnapIn Among these, there are also the standard commandlet packages, starting with MicrosoftPowerShell* (see Figure 108) Get-PSSnapin registered, however, lists all registered snap-ins, regardless of whether they are active in the current console Figure 109 shows the snap-in WorldWideWings_PowerShell_Extensions, which is not active in the console (see Figure 109)
Commandlet Extensions
10 TIPS, TRICKS, AND TROUBLESHOOTING
Figure 108 Active PowerShell snap-ins
Figure 109 All commandlets registered on the system
List of Available Commandlets
To get a list of all commandlets in a speci c snap-in, you can lter for the property PSSnapIn in the class CmdletInfo, as follows:
10 Tips, Tricks, and Troubleshooting
Get-command | where { $_pssnapin -like "Pscx" }
Get-command | where { $_pssnapin -like "ITVisions_PowerShell_Extensions" }
Get-command | where { $_pssnapin -like "questactiverolesadmanagement" }
Ambiguous Commandlets
It might happen that you activate different snap-ins that de ne commandlets with the same name, because there is no central registry for commandlets When you encounter this problem, WPS answers the call of ambiguous commandlets with an error (see Figure 1010)