EventVwr Command-Line Parameters in Windows 8

Update: I’m told that this command-line option works in Windows 7, as well.  So it’s not a change for Windows 8/2012.  I just didn’t have a Windows 7 machine handy to test it.

The command-line parameters for the Event Viewer have changed in Windows 8 (and Windows Server 2012, I assume).  To launch Event Viewer to connect to another machine from the command-line, execute the following:

I just ran Sysinternals’ strings.exe command to determine how to do this.  If I figure out more of the parameters, I’ll update this post.

Rob

This post was migrated from https://blogs.msdn.microsoft.com/rob/2012/07/02/eventvwr-command-line-parameters-in-windows-8/.

Afraid of PowerShell? Watch this video now.

I have been working more and more with PowerShell lately and I love it.  If you want to watch a great introductory 75 minute video to get up to speed quickly, look no further than here:

Windows PowerShell Crash Course

https://channel9.msdn.com/Events/TechEd/NorthAmerica/2012/WSV321

It is presented by Don Jones and Jeffrey Snover.  They share a number of great tricks and tips, too.  I may start posting daily tricks and tips either from the video or that I learn as I experiment with PowerShell.  Hopefully they won’t mind me re-posting their tips.

Rob

This post was migrated from https://blogs.msdn.microsoft.com/rob/2012/06/27/afraid-of-powershell-watch-this-video-now/.

Windows 8 / Server 2012 Tip of the Day: Logging Off (and Switching User)

I don’t know why, but I keep forgetting how to log off of Windows 8 / Server 2012 systems.  To do so, go to the Start “screen”, click on your user account picture/name in the upper-right hand corner of the screen, and select “Sign out”.  Or you can select “Switch User” from here.

Rob

This post was migrated from https://blogs.msdn.microsoft.com/rob/2012/06/19/windows-8-server-2012-tip-of-the-day-logging-off-and-switching-user/.

Deleting Windows Services that won’t uninstall

I created a Windows Service installer using WiX and included a custom action that called PowerShell to run a script.  Unfortunately, I called the script with the wrong parameters and then the service would not uninstall.  So, I tried a lot of different tricks and finally found a recommendation on the web to run the sc.exe command with the delete parameter.  This was the only solution that worked, so I thought I’d share it here.  I executed:

Note that to execute the same command from PowerShell, you must specify the full path to sc.exe because PowerShell has a default alias for sc assigning it to Set-Content.  I executed it as follows:

I hope this saves someone else some grief in the future.

Rob

This post was migrated from https://blogs.msdn.microsoft.com/rob/2012/06/07/deleting-windows-services-that-wont-uninstall/.

Want to add color to PowerShell code in your docs?

I was writing a Word document and wanted syntax highlighting for my PowerShell scripts.  It turns out that ISE (Integrated Scripting Environment) has an extension for copying text with color (and for copying text with color as HTML).  Just do the following:

  1. Install the PowerShellPack.msi file from here.
  2. Open ISE and your .ps1 PowerShell file.
  3. In the bottom third of the window, enter the following PowerShell command:
    1. Import-Module PowerShellPack
  4. You will now see an Add-ons menu in ISE; it may have already been there.
  5. Highlight the PowerShell code you wish to copy and choose Add-ons, IsePack, Edit, Copy-Colored from the menu.
  6. Now switch to Word and paste in your PowerShell code with full syntax highlighting.
  7. You can also use Copy-ColoredAsHtml to put syntax-highlighted HTML into your clipboard.
  8. Note that Ctrl-Shift-C will perform the Copy-Colored function and Ctrl-Alt-Shift-C will perform the Copy-ColoredAsHtml function.

This information came from “How to Insert Formatted Windows PowerShell Code on TechNet Wiki (en-US)“.

Load more