Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all 3333 articles
Browse latest View live

Use PowerShell to parse event log for shutdown events

0
0

Summary: Using the Windows PowerShell Get-EventLog cmdlet makes it easy to parse the system event log for shutdown events.

One of the great things about central Florida during this time of the year is that there are certain fruits, such as red grapefruit, that are in season. This is also true of a certain variety of tangelo that is super sweet.

However, as sweet as both of these are, neither is a sweet as parsing the event log with Windows PowerShell. It makes it easy to gain insights into what is going on with your computer, server, or whatever device.

Using Get-EventLog cmdlet is super easy

There are two basic Windows PowerShell cmdlets that parse the event log. One, Get-WinEvent, is super powerful, but a bit tricky to use. The other, Get-EventLog, is super easy, and it works great for ad hoc parsing. Today I will use Get-EventLog because I am only working with a classic event log, and I am only working on my local computer.

Since Windows XP and Windows 2003, Windows has had the Shutdown Event Tracker, which will track what is going on with shutdowns. It writes to the System event log and the source is User32. I can search for this information directly from the System event log by using the Get-EventLog cmdlet:

Get-EventLog -LogName system -Source user32

The command and output are shown in the following image:

Image of command output

I also know from working with the Microsoft Operations Management Suite that there are two event IDs associated with the Shutdown Event Tracker. One is normal, and the other is an unexpected shutdown.

Note  For more information about Microsoft Operations Management Suite Search capabilities, see my series of blog posts on the MSOMS Team blog.

At this point, I do not need to know which event is normal or unexpected. All I want to do is to group them by EventID, then I can dive into them in a little bit. Here is the command that I use:

Get-EventLog -LogName system -Source user32 | group EventID

My output, which appears in the following image, tells me that I only have a single EventID: 1074.

Image of command output

Dive into the data

Let me look at one instance of the 1074 event. To this, I send the output to the Format-List cmdlet and select all of the properties. In the following command, fl is an alias for Format-List and * means to choose all of the properties:

Get-EventLog -LogName system -Source user32 -Newest 1 | fl *

The output includes the machine name, the time the event was generated, the user name, the message, and other properties. By looking at these details, I can decide what information I actually find useful, and that will guide my selection process. Here a screenshot of the event record details:

Image of command output

Sort the data

Because I know there is only one EventID on my system from the User32 source, I know that I can leave that information out. From looking at the event record details, I can see that I am only interested in two pieces of information (properties of the object). These are the TimeGenerated and the Message. So, I select that information in my revised query:

Get-EventLog -LogName system -Source user32 | Select TimeGenerated, Message

   Note  In my Windows PowerShell console running Windows PowerShell 5.0, I can Tab expand the property names in my Select statement.

Here is the output from the command:

Image of command output

It looks like my time is displayed in descending fashion. But I am more interested in the message. Because the message looks somewhat redundant, I think I might be able to sort on that property and receive meaningful data:

Get-EventLog -LogName system -Source user32 | Select TimeGenerated, Message | sort message

The command and its output are shown here:

Image of command output

That looks good, and I can see that the RuntimeBroker initiated a number of shutdowns, but there were also a few by the winlogon. I can easily pipe the output to the Format-Table cmdlet and tell it to wrap. By doing this, I will be able to see the content of the Message property. The following command is a one-liner that is broken at the pipeline character for readability (ft is an alias for Format-Table):

Get-EventLog -LogName system -Source user32 | Select TimeGenerated, Message |

 sort message | ft -Wrap

Here is the command and its output:

Image of command output

If I would like a good overview of various reasons, I can select unique messages and still wrap them. When I do this, I do not need the time generated, I am only looking at the reasons:

Get-EventLog -LogName system -Source user32 | Select Message -Unique | ft -Wrap

This command and its output are shown here:

Image of command output

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. Also check out my Microsoft Operations Management Suite Blog. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy


PowerTip: Add number to existing variable value

0
0

Summary: Learn how to easily add a number to an existing value stored in a variable and update the value of the variable.

Hey, Scripting Guy! Question How can I use Windows PowerShell to add a number to a value stored in a variable so that I can update the
           value in that variable with the number and store the number back into the variable?

Hey, Scripting Guy! Answer Use the += operator. This example adds 3 to the value stored in the $a variable and then stores the new
           value back into the variable:

PS C:\> $a = 5

PS C:\> $a += 3

PS C:\> $a

8

How to contribute to PowerShell documentation

0
0

Summary: Learn how to contribute to Windows PowerShell documentation via various community initiatives.

Today’s guest blog post is by Microsoft premier field engineer, Ashley McGlone. He will be speaking at PowerShell Saturday, so come join us for a great day of PowerShell learning. For more information, see PowerShell Saturday in Tampa, FL, March 19, 2016. Follow Ashley through his TechNet blog, Goatee PFE, and Twitter. Here’s Ashley…

How many times have you found PowerShell documentation that was not up-to-date? Or maybe you could not even find the documentation you needed. Today I’ll be discussing ways that you can fill the gap.

PowerShell community

One of the things I have enjoyed over these years of doing PowerShell is the community. By community, I mean the people I meet online and offline, including Twitter, Facebook, LinkedIn, blogs, forums, user groups, events, and conferences. The PowerShell team at Microsoft has intentionally engaged the community in a way that sets a high bar for the other teams at Microsoft. The value of community has been proven over the last few releases of Windows Management Framework (WMF). PowerShell feedback from the community has guided the features and fixes the whole way.

Image of classroom

Community documentation

As announced last year (see The New Home of DSC Documentation), the documentation and release notes for PowerShell are now open source on GitHub. This means you (as part of the community) can personally contribute and correct PowerShell documentation. You will even get proper credit for your contributions by seeing your name listed in the articles you have written or updated.

Image of article title

Career booster

Many people do not like attention for themselves. The thought of your name in lights could be annoying. Most of us just want to see the community get accurate documentation. That is noble. But think about this:

When a potential employer sees your picture and name beside articles on a Microsoft web property, does that hurt or help your prospects?

I think it helps your career, and it gives you a sense of satisfaction at the end of the day. “I did that!”

Image of code

Behind the scenes

The PowerShell documentation you find on MSDN begins its journey at GitHub.

What is GitHub?

GitHub is probably the largest open-source collaboration platform in the world. Trust me, you want to learn this. It is what all the cool kids are doing these days. I’m still learning.

This table summarizes the documentation parts:

The documentation

you see here…

is maintained here…

PowerShell

TechNet docs

n/a

WMF 5.0 Release Notes

MSDN docs

GitHub source

PowerShell DSC

MSDN docs

GitHub source

This table summarizes the code parts:

The code

you see here…

is maintained here…

TechNet Script Gallery

TechNet Gallery

n/a

PowerShell Gallery

PowerShell Gallery

*GitHub source

PackageManagement

Windows Management Framework

GitHub source

* To be clear, the community can contribute directly to the PowerShell Gallery, but the Microsoft open-source contributions are shared publicly on GitHub. To learn more, see Registration is Now Open to Publish on PowerShell Gallery.

When you compare the previous tables, do you notice a pattern? I am not making any announcements, and I don’t have too much insider information. But judging from public knowledge, the pattern seems to indicate that the documentation on TechNet is moving to the other platform over time.

How to contribute to documentation

The PowerShell team has created a guide called Contributing to PowerShell Documentation, which explains the process for contributing to documentation. Here is the general flow:

  • Get a GitHub account.
  • Read the brief contribution guide.
  • Complete the Contribution License Agreement (CLA).
  • Identify where you want to contribute or revise. This means checking current issues to see if others are working on it.
    • If no one else is working on it, open an issue and start.
    • If others have logged it, contribute to their effort.
  • Create a fork in GitHub.
  • Compose your content by using:
  • Create a pull request in GitHub.

At first this may seem like a lot of effort. However, once you get past the first setup steps, it is fairly easy.

For today’s post, I want to focus on how to write the content with Visual Studio Code and then how to create your first GitHub fork and pull request.

Writing Markdown content with Visual Studio Code

I am going to date myself with this statement. I remember word processing in the 1990s with Word Perfect for DOS. You had a view called reveal codes that showed the text formatting elements. This is a lot like that, or HTML, or any other markup language.

Let’s look at what you need to know to write PowerShell documentation with Visual Studio Code. It’s really not that hard, but it might take some practice.

Setting up Visual Studio Code

Here’s a walk-through to get started:

1. Download Visual Studio Code for free. Install it. Optionally, follow Visual Studio Code on Twitter.

2. Launch Visual Studio Code, and create a new file in the folder of your choosing. Save it with the .md extension.

3. Click the Split Editor and Open Preview buttons highlighted in the following screenshot. Now you can see your source and preview side-by-side.

Image of menu  

4. Now start typing your content. Put line breaks after each sentence. This way it is easier to track changes later on GitHub.

Markdown syntax

PowerShell documentation is written in Markdown. It is easier than HTML, but not quite as powerful. You will find that markdown is very light-weight, user-friendly, and fast. There are several flavors of Markdown, and we will use the GitHub flavor that is cited in the contribution guide. In addition to the GitHub markdown reference, there are many popular sites online with tutorials.

Following are a few screenshots that highlight some popular formatting options for writing PowerShell docs. These example come from my document, Credentials Options in Configuration Data. The GitHub source is here: Credentials Options in Configuration Data.

Image of code

Image of code

Image of code

Here is a summary of the formatting used in these screenshots:

  • Two carriage returns make a new paragraph.
  • Greater than ( > ) indents a block quote.
  • Asterisk at the beginning of a line makes a bullet.
  • Single asterisk surrounding text makes italics.
  • Double asterisk surrounding text makes bold.
  • Single backticks ( ` ) surrounding text is for code elements.
  • Triple backticks before and after a block of lines turns it into code. Well-known code formatting is applied by naming it after the first set of backticks.
  • To make links, surround the link text with square brackets and surround the link URL with round parentheses.

See the links in the screenshots for more formatting options. Remember that .md files are plain text with a few extra characters for formatting. It is actually quite easy and fun!

Publishing your documentation

Newb alert! I am not a trained GitHub professional. The following guidance is my own inefficient process. Please be kind to us OPS folks learning DEV stuff. I know you can do this better than me, so help me out in the comments section.

Now I have a text file that needs to get to GitHub. There are a number of ways to do this. GitHub pros will use any one of many command line (or GUI tools. See GitHub for Windows). I’m not there yet. I cheat and use the web interface.

If you are updating an existing article, you can simply copy and paste your changes from Visual Studio Code into the GitHub web interface where you have chosen to edit the documentation. Here are the steps:

  • Browse to the GitHub file that contains the documentation you want to edit.
  • On the top-right side of the article click the pencil to Edit the file in your fork of the project:

Image of menu

This makes a copy of the file in your own GitHub account, called a fork.

  • Now you can edit the text in the web interface. This is where you want to copy/paste to/from Visual Studio Code and edit the Markdown.
  • After you have completed your edits, you can create a pull requestat the bottom.
    • A pull request tells the owner of the original file that you want them to pull your changes into their copy for publishing.
    • When you submit the pull request, give it a title and description for the change you are making. This helps the owner of the file understand what you are changing and why.
    • Click the button to submit the pull request. Your change is given a number, and you will see a summary of your edits.
    • When the owner approves your edits, you will get a notification in your GitHub account. If they have questions or do not approve, they will probably make notes on the request and ask for clarification or other edits.

Also worth noting is that the GitHub pros have already synced a local copy of the files from GitHub to their local machine, and that is what they open directly in Visual Studio Code. In that case, you can edit the file directly and post your changes with a pull request by using local GitHub tools instead of the web interface. I aspire to do this.

If you are submitting an entirely new file, you can create that in your own GitHub account. Then submit a pull request to the master branch of the documentation.

To learn more about GitHub, see this intro video: A Crash Course in Version Control and Git with Warren Frame (my buddy, aka PSCookieMonster).

The Scripting Guy is famous for closing his PowerShell posts by saying, “…and that’s all there is to doing x with PowerShell!” I am not so bold in this case. There is an art to using GitHub, and I am still an apprentice. Now you know what I know. I hope this helps you on your journey to making an impact in the PowerShell community. Give it a try. Boost your career and the community. Thanks in advance!

~Ashley

Thank you, Ashley. This is great.

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. Also check out my Microsoft Operations Management Suite Blog. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy

PowerTip: Return remainder after dividing two numbers

0
0

Summary: Use Windows PowerShell to return the remainder after dividing two numbers.

Hey, Scripting Guy! Question How can use Windows PowerShell to divide two numbers and only return the remainder (called a modulo operation)?

Hey, Scripting Guy! Answer In Windows PowerShell, the modulo operator is the % sign. Here are a few examples of how to use it:

PS C:\> 3 % 2

1

PS C:\> 5 % 2

1

PS C:\> 11 % 2

1

PowerTip: Use PowerShell to find all methods from .NET Framework class

0
0

Summary: Learn how to find all methods from a .NET Framework class by using Windows PowerShell.

Hey, Scripting Guy! Question How can I use Windows PowerShell to show both static and dynamic methods for a .NET Framework class?

Hey, Scripting Guy! Answer Use the GetMethods method from the class. This example uses the System.Math class to return the
           method name and if the method is static:

[math].GetMethods() | Select Name, IsStatic -Unique

PowerTip: Find information about .NET Framework method with PowerShell

0
0

Summary: Learn how to use Windows PowerShell to find information about a .NET framework method.

Hey, Scripting Guy! Question How can I use Windows PowerShell to find basic information about a particular .NET Framework method?

Hey, Scripting Guy! Answer Use the GetMethod method from the class, for example:

 [math].GetMethod("Tan")

Note  The method name is case sensitive and it must be in double quotation marks.

PowerTip: Find properties of .NET Framework class with PowerShell

0
0

Summary: Learn how to use Windows PowerShell to display properties of a .NET Framework class.

Hey, Scripting Guy! Question How can I use Windows PowerShell to easily display properties of a .NET Framework class?

Hey, Scripting Guy! Answer Pipe the type accelerator to the Get-Member cmdlet and specify the MemberType property,
           for example:

[string] | gm -MemberType Properties

Notegm is an alias for Get-Member.

PowerTip: Use PowerShell to view properties and their values for a .NET Framework class

0
0

Summary: Learn how to view properties and the associated values of those properties of .NET Framework classes with Windows PowerShell.

Hey, Scripting Guy! Question How can I use Windows PowerShell to view the properties and their values from a .NET Framework class,
           such as System.String?

Hey, Scripting Guy! Answer Use the Type accelerator [string], pipe the output to the Format-List cmdlet, and use an asterisk to
           select all properties:

[string] | fl *

Note: fl is an alias for Format-List.


February community PowerShell spotlight

0
0

Summary: Windows PowerShell MVP, Teresa Wilson, shares her roundup of Windows PowerShell activities for the coming months.

Hello scripters,

Teresa Wilson here. I hope you had a marvelous weekend and are ready to tackle this week. Ed is finally getting back to normal and we have a few trips coming up—all Windows PowerShell related.

Arizona PowerShell User Group March 1 in Phoenix

First of all, we will be in Phoenix, AZ on March 1, 2016 for the Arizona PowerShell User Group (AZPOSH) meeting. I also heard from a little birdie that my good friend Jason Helmick will be there. The signup is not available yet (they are still promoting their February meeting) but as soon as it is, I will tweet it and put it on the Scripting Guys Facebook page. I might even try to talk Ed into posting another short blog about it with signup information.

PowerShell Saturday #010 March 19 in Tampa

Next is PowerShell Saturday #010 in Tampa, Florida at the University of South Florida (USF) on March 19, 2016. We have an amazing lineup of speakers and sessions. There will be something for everyone—no matter what your skill level. We have five MVPs, six Microsoftees, and two user group leaders confirmed. Here is a link to information about the PowerShell Saturday #010 speakers. This will be a day loaded with PowerShell goodness.

I am not going to write about the sessions in this post. For more information, please read the Session synopses. We will be adding a few more sessions in the upcoming days. There will be four tracks with five sessions in each track. This means roughly five hours of training for you.

We are not doing this to make money. We are charging a small fee to cover the cost of the food, and if we have any leftover, we will buy more swag to give away.

Our sponsors are on board to help us with the expenses that go along with an event. We could not put on a day of training like this without the sponsors. And we also want to recognize the speakers who pay their own travel expenses and the companies that pay the travel for their employees to attend. We have speakers coming from Canada, Wisconsin, Utah, Tennessee, Ohio, Georgia, and all over Florida.

I would be remiss if I did not mention Ed and my cohost for this day. Microsoft evangelist, Blain Barton (@blainbar on Twitter), has been amazing in getting this show on the road. Our other partner in crime is Will Anderson, our webmaster. Will is an MVP and Honorary Scripting Guy  (@GamerLivingWill on Twitter).

With all this knowledge and PowerShell goodness just waiting to unfold, what are you waiting for? Sign up today: Register: PowerShell Saturday #010.

~Teresa

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. Also check out my Microsoft Operations Management Suite Blog. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy

PowerTip: Get password from PowerShell credential object

0
0

Summary: Learn how to retrieve the password from a Windows PowerShell credential object.

Hey, Scripting Guy! Question I am having a problem connecting to an application via Windows PowerShell. How can I verify the user name and
           password that was supplied to the credential object?

Hey, Scripting Guy! Answer Assuming you have permissions to the object, you can use the GetNetworkCredential method, for example:

$a = Get-Credential

$a.GetNetworkCredential() | fl *

Convert a web page into objects for easy scraping with PowerShell

0
0

Summary: Learn how to use Windows PowerShell 5.0 to scrape a web page so that you can easily return parsable objects.

Good morning. Ed Wilson here, and today I have a guest blog post by Doug Finke...

When surfing the PowerShell Gallery, you'll find that each module has a web page with a version history, for example:

Image of list

Wouldn't it be great if you could get this information at the command line? Click here for a 20 second video that shows the code to do it.

How to do web scrapping

This approach will only work in Windows PowerShell 5.0, because it uses the new ConvertFrom-String function to convert the parsed HTML text into objects.

It's a simple approach. First, use Invoke-WebRequest to get the HTML back from the web page. Then, AllElements returns a list of objects that you pipe to Where and do a match on versionTableRow. You grab the InnerText property and pipe all of this to ConvertFrom-String using the contents of $t as the template to convert the text to objects with the property names Name, Version, Downloads, and PublishDate.

function Get-PSGalleryInfo {

    param(

        [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)]       

        $Name

    )

    Begin {

$t = @"

{Name*:PowerShellISE-preview} {[version]Version:5.1.0.1} (this version) {[double]Downloads:885} {[DateTime]PublishDate:Wednesday, January 27 2016}

{Name*:ImportExcel} 1.97  {Downloads:106} Monday, January 18 2016

"@

    }

 

    Process {

        $url ="https://www.powershellgallery.com/packages/$Name/"

       

        $r=Invoke-WebRequest $url

        ($r.AllElements | Where {$_.class -match 'versionTableRow'}).innerText |

            ConvertFrom-String -TemplateContent $t

    }

}

How to figure out the content of class

Launch your browser and navigate to the ImportExcel 1.98 module. You should be able to right-click the page and find an option called View page source. When you click it, you'll get another tab in your browser, which shows you the underlying HTML. Scroll down (or use Search) for text that looks familiar in the rendered page.

Here you can see an HTML class attribute that contains versionTableRow. For other pages you want to scrape, you need to examine the HTML to figure out what uniquely identifies what you want to extract. Sometimes it's as easy as this:

Image of code

Next, you can see the text returned with this PowerShell snippet:

$r.AllElements | Where {$_.class -match 'versionTableRow'}).innerText

Use that to create the TemplateContent for ConvertFrom-String, which transforms the text to objects.

For a great write up on how to work with ConvertFrom-String, check out this post on the Windows PowerShell blog: ConvertFrom-String: Example-based text parsing.

~Doug

Thank you, Doug, for that way cool post. Join me tomorrow for more cool Windows PowerShell stuff.

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. Also check out my Microsoft Operations Management Suite Blog. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy 

PowerTip: Learn about PowerShell default parameter values

0
0

Summary: Learn about the default parameter values in Windows PowerShell.

Hey, Scripting Guy! Question How can I find more about default parameter values in Windows PowerShell?

Hey, Scripting Guy! Answer Use the Get-Help cmdlet and search for *defaultParameter*. The following command returns a
           list of Help topics that provide this information:

help *DefaultParameter*

Find DSC resources that are available in the PowerShell Gallery

0
0

Summary: Learn how to use Windows PowerShell commands to easily find Desired State Configuration resources that are available in the PowerShell Gallery.

One of the cool things about Windows PowerShell is that it makes exploring data easy. And everything is data in some form. Whether it is local or remote, whether it is plain text; a .csv, .tsv, or .xml file…whatever it is, it is still data.

Even a list of cmdlets, functions, scripts, modules, or whatever in the Windows PowerShell world is data—and from a usability stand point, it is valuable data. So I can use Windows PowerShell to learn about what I can do with Windows PowerShell. The PowerShell Gallery makes that an even richer proposition. The PowerShell Gallery home page is shown here:

Image of menu

Use Find-DSCResource

When I use the Find-DSCResource command, a long list of DSC resources come back:

Image of command output

In fact, when I run it, I get back 461 DSC resources:

PS C:\> Find-DscResource | measure

Count    : 461

Average  :

Sum      :

Maximum  :

Minimum  :

Property :

That is quite a lot of information to scroll through. So, to get an idea of how many DSC resources are in which modules, I decide to group and sort. Here is my command:

Find-DscResource | group modulename | sort count -Descending

Here is the output from the command:

Image of command output

There are quite a few DSC resources in the xSharePoint and xExchange modules, it would appear. To get an idea of how many modules there, I select unique module names:

Find-DscResource | select modulename -Unique

To find how many modules I have, I add measure:

PS C:\> Find-DscResource | select modulename -Unique | measure

Count    : 119

Average  :

Sum      :

Maximum  :

Minimum  :

Property :

Wow, that is quite a lot!

Filter DSC resources

If I want to find a specific DSC resource, I can do one or two things. The first, and perhaps most obvious, is to search by module. For example, if I am interested in doing web things, I may want to find DSC resources that have the letters web in the module name:

Find-DscResource -moduleName *web*

Image of command output

It would appear that I cannot use a wildcard character for the resource name. So, when I type the following queries, I do not get anything back:

PS C:\> Find-DscResource -Name “*update*”

PS C:\> Find-DscResource -Name “*reboot*”

PS C:\> Find-DscResource -Name *reboot*

PS C:\> Find-DscResource -Name *update*

PS C:\>

But it also seems that I can use wildcard characters for the module name, for example:

Find-DscResource -moduleName *update*

Image of command output

But the easier way to do things is to use the -Filter parameter. By using this, I can find things I would not otherwise imagine. Here are a few example commands:

Find-DscResource -Filter “update”

Find-DscResource -Filter “reboot”

The cool thing is that the -Filter parameter will search the ModuleName field and the Resource name fields. Here is the output from the two commands:

Image of command output

The good news is that there are now hundreds of DSC resources in the PowerShell Gallery. The even better news is that I can use Windows PowerShell to find them.

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. Also check out my Microsoft Operations Management Suite Blog. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy

PowerTip: Find DSC resources with PowerShell

0
0

Summary: Learn how to find DSC resources with Windows PowerShell.

Hey, Scripting Guy! Question How can I use Windows PowerShell to find DSC resources that are available in the PowerShell Gallery?

Hey, Scripting Guy! Answer Use the Find-DSCResource command.

 

PowerTip: Disable plug and play device with PowerShell

0
0

Summary: Learn how to disable a plug and play device with Windows PowerShell.

Hey, Scripting Guy! Question How can I use Windows PowerShell to disable a plug and play device?

Hey, Scripting Guy! Answer Use the Disable-PNPDevice cmdlet and specify the instance ID, for example:

Disable-PnpDevice -InstanceID  ‘USB\VID_5986&;PID_0266&;MI_00\7&;1E5D3568&;0000′


PowerTip: Use PowerShell to disable scheduled task

0
0

Summary: Learn how to use Windows PowerShell to disable a scheduled task.

Hey, Scripting Guy! Question How can I use Windows PowerShell to disable a scheduled task?

Hey, Scripting Guy! Answer Use the Disable-ScheduledTask cmdlet and specify the task name, for example:

Disable-ScheduledTask -TaskName “SystemScan”

PowerTip: Use PowerShell to disable all scheduled tasks in folder

0
0

Summary: Use Windows PowerShell to disable all scheduled tasks in a specific folder.

Hey, Scripting Guy! Question How can I use Windows PowerShell to disable all scheduled tasks in a particular folder?

Hey, Scripting Guy! Answer Use the Get-ScheduledTask cmdlet to enumerate the scheduled tasks in the folder, and then pipe the objects to the Disable-ScheduledTask cmdlet, for example:

Get-ScheduledTask -TaskPath “\UpdateTasks\” | Disable-ScheduledTask

PowerTip: Use PowerShell to disable constrained delegation

0
0

Summary: Learn how to use Windows PowerShell to disable constrained delegation.

Hey, Scripting Guy! Question How can I use Windows PowerShell to disable constrained delegation authorization so that a user who is remotely connected to a SMB server cannot configure resources?

Hey, Scripting Guy! Answer Use the Disable-SmbDelegation cmdlet, and specify the client and the SMB server, for example:

Disable-SmbDelegation –SmbServer “FileServer01″ –SmbClient “HVSVR01″

 

PowerTip: Enable PerfMon counters for ODBC connection pooling with PowerShell

0
0

Summary: Learn how to use Windows PowerShell to enable Windows Performance Monitor counters for ODBC connection pooling.

Hey, Scripting Guy! Question How can I use Windows PowerShell to enable Windows Performance Monitor (PerfMon) counters so I can troubleshoot Open Database Connectivity (ODBC) connection pooling?

Hey, Scripting Guy! Answer Use the Enable-ODBCPerfCountger cmdlet and specify the platform (32 bit or all). Here is an example:

Enable-OdbcPerfCounter -Platform 32-bit

PowerTip: Enable and disable ODBC performance counter settings with PowerShell

0
0

Summary: Learn how to enable and disable a collection of ODBC performance counter settings for troubleshooting.

Hey, Scripting Guy! Question How can I use Windows PowerShell to enable the ODBC performance counters, run commands in a script, and then disable the counters?

Hey, Scripting Guy! Answer You can store a returned object for later use when you enable the performance counters by using the -PassThru parameter, for example:

$perfCounter = Enable-OdbcPerfCounter -Platform 32-bit -PassThru
<Execute some ODBC applications that are using ODBC pooling>
Disable-OdbcPerfCounter $perfCounter

Viewing all 3333 articles
Browse latest View live




Latest Images