Power Tips

Share |

Join PowerShell.com!
Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Powershell Plus


13 Free SQL Tools from Idera


Free Ebook: Mastering Powershell

Welcome to the archive of tips delivered through Tobias' Tip of the Day RSS Feed and Your Power Tip of the Day email. Subscribe in the sidebar to get the latest tips!

Sort by: Most Recent | Most Viewed | Most Commented
  • Entering Passwords Securely

    You can use Read-Host -asSecureString to be able to type a password with hidden characters: $password = Read-Host -asSecureString 'Password' This will return a secure string. You should use this to get the password back into plain text: $password...
  • Find Out If A Machine Is Connected To The Internet

    Ever wondered if a machine was connected to the Internet? Here is how you can find out: $networkListManager = [ Activator ]:: CreateInstance ([ Type ]:: GetTypeFromCLSID ([ Guid ] "{DCB00C01-570F-4A9B-8D69-199FDBA5723B}" )) $connections = $networkListManager...
  • Sorting IP Addresses

    Sorting or comparing IP addresses won't initially work because PowerShell uses alphanumeric comparison. However, you can compare or sort them correctly by casting IP addresses temporarily to the type System.Version: $iplist = "10.10.10.1"...
  • Speed Up The Reading of Large Text Files

    When you use Get-Content to read in text files, you may initially be disappointed by its performance. However, Get-Content is slow only because it emits each line to the pipeline as it reads the file, which is time-consuming. You can dramatically speed...
  • Accessing Web Services

    Did you know PowerShell can access public and private Web services? The piece of code below will connect to a global weather service providing airport weather reports from around the globe: $a = New-WebServiceProxy 'http://www.webservicex.net/globalweather...
  • Create HTML report in style

    Also, here is a template that shows you how to change to a nicer font if you want to export PowerShell results as HTML report.. It will generate a process list and display it in a simple window: $head = @ ' <style> body { font-family:Consolas...
  • Launching Scripts Externally

    For example, you should use this line if you want to launch a *.ps1 PowerShell script externally from outside PowerShell via desktop shortcut or from inside a batch file: powershell.exe -nologo -executionpolicy bypass -noprofile -file "C:\myscript...
  • Get All Logged On Users

    In a previous tip, you learned how to determine who the user is logged onto the physical machine. However, this will not discover logged-on terminal service users or users inside virtual machines. You must use the code below to find those: $computername...
  • Comparing Hotfixes

    If you want to check hotfixes, you should compare installed hotfixes on a master image with some other machine. Go ahead and use Compare-Object and this approach: $machine1 = Get-HotFix -ComputerName server-master $machine2 = Get-HotFix -ComputerName...
  • Backing Up Event Log Files

    WMI provides a method to backup event log files as *.evt/*.evtx files. The code below creates backups of all available event logs: Get-WmiObject Win32_NTEventLogFile | ForEach-Object { $filename = "$home\" + $_ . LogfileName + '.evtx'...
  • Opening Excel Reports in a New Window

    When opening CSV files with Excel from PowerShell, you may receive exceptions if the particular file was opened by Excel already: Invoke-Item c:\files\ report.csv You can work around this by telling Excel to open a new window for the CSV file. Here is...
  • Loading .EVT/.EVTX Event Log Files

    If customers send in dumped event log files, there is an easy way to open them in PowerShell and analyze content: Get-WinEvent! The -Path parameter will allow you to read in those binary dumps and display the content as an object. You should use this...
  • Checking Loaded Formats

    PowerShell Snapins and Modules can add format files that describe how Powershell should auto-format object types. Use this line to check which format files have been loaded: $host . Runspace.RunspaceConfiguration.Formats | Select-Object -ExpandProperty...
  • Checking Loaded Assemblies

    Use this line to check which .NET assemblies are currently loaded into PowerShell: $host . Runspace.RunspaceConfiguration.Assemblies ReTweet this Tip!
  • Checking -STA Mode

    PowerShell needs to run in STA mode to display Windows Presentation Foundation (WPF) windows. ISE runs in STA mode by default whereas the console will need to be launched explicitly with the -STA switch. To check whether STA mode is currently enabled...
« First ... < Previous 72 73 74 75 76 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.