Step 1 – Capture the output To create a parser you have to capture the output so you can analyze it deeply enough to understand the structure. Capturing the output is easy. Copy netstat > netstat-output.txt Step 2 – Analyze the output The goal of this analysis is to isolate the import...
Example 16: Capture connection statistics via -StatisticsVariable parameter PowerShell Copy Import-Module SQLServer Invoke-Sqlcmd -ServerInstance localhost -StatisticsVariable stats ` -Query 'CREATE TABLE #Table (ID int); INSERT INTO #Table VALUES(1), (2); INSERT INTO #Table VALUES(3); SELECT...
These folders can be navigated like the filesystem, as is shown in this screen capture: Figure 1: Navigating the SQLServer: PowerShell Drive Now, by navigating to the Databases folder under an instance of SQL Server, you can use the following command to send the list of databases to a web...
As you can see, I created a $date variable that contains an object representing the current time. I then used some documented methods supported by the object to show how you can easily get the date and time five minutes later, and then five hours later. If I wanted to get values from...
Adding Objects to an Array with additional properties Adding quotes to variable's value Adding rows to datagridview by column names Adding secondary smtp addresses to Distribution Groups Adding the contents of an array Adding the server name to output adding timeout limit to System.Diagnostics.Proces...
Example 16: Capture connection statistics via -StatisticsVariable parameter PowerShell Copy Import-Module SQLServer Invoke-Sqlcmd -ServerInstance localhost -StatisticsVariable stats ` -Query 'CREATE TABLE #Table (ID int); INSERT INTO #Table VALUES(1), (2); INSERT INTO #Table VALUES(3); SELECT...
If the line matches the examples given in the pattern, values are extracted and passed to the output variable.The sample data, $template, provides two different phone formats:425-123-6789 (206) 987-4321The sample data also provides two different age formats:...
The first command gets the site object with the code of PS1 and stores the object in the $WmiObject variable.The second command uses the pipeline operator to pass the site object stored in $WmiObject to ConvertTo-CMIResultObject, which converts the site object to an IResultObject....
The-matchoperator works in conjunction with the$matchesautomatic variable. Each time a-matchor a-notmatchsucceeds, the$matchesvariable is populated so that each capture group gets its own entry. If the capture group is named, the key will be the name of the group, otherwise it will be the...
As you can see, we’re using the Add_KeyDown method to add the ENTER key ($_.KeyCode –eq "Enter") to our “capture” list. We’re also specifying what we want to happen if and when the user does press the ENTER key: we want to set the value of a variable $x to the value...