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
  • Filtering Files or Folders with PowerShell

    To filter folder content by file or folder, check whether the Length property is present. It is present for files and missing in folders: Dir $env:windir | Where-Object { $_ . Length -eq $null } Dir $env:windir | Where-Object { $_ . Length -ne $null ...
  • Office365 Cmdlets with PowerShell

    Office365 comes with a complete set of PowerShell cmdlets. To review the cmdlets and what you can do with them, visit this URL: http://onlinehelp.microsoft.com/en-us/office365-enterprises/hh125002.aspx ReTweet this Tip!
  • Use Select-String with Context in PowerShell

    Select-String can find lines with a specific keyword. It can also include context-relevant lines before and after that line. This will filter the result from ipconfig to focus on your network adapter parameters only: ipconfig | Select-String LAN -context...
  • Launching Applications with PowerShell

    When you launch *.exe-applications with arguments, you may get exceptions because PowerShell may misinterpret the arguments. A better way to do this is using Start-Process and then separate file path and arguments with the parameters -FilePath and -ArgumentList...
  • Managing File System Tasks with PowerShell

    If you need to list all cmdlets that deal with file system-related tasks, try this: Get-Command -Noun item * , path Many of these cmdlets have historic aliases that will help you guess what they are doing: Get-Alias -Definition *- item * , *- path * ...
  • Appending CSV Data with PowerShell

    To append a CSV file with new data, first of all make sure the type of data you append is the same type of data already in a file (or else column names will not match). This creates a list of unique running processes (so it will not list duplicate process...
  • Create CSV without Header using PowerShell

    ConvertTo-CSV can create comma separated values (CSV) on the fly but it always adds a new header. To create CSV data without columns, take a look at some piece of code - it removes the first two lines: $filepath = " $env:temp\rawcsv.txt " $processes...
  • Checking Array Content with Wildcards in PowerShell

    In a previous tip we illustrated how -like can work on array. To iterate on that, check out how -like (in contrast to -contains) allows the use of wildcards to check for array elements: PS > ' Peter ' , ' Mary ' , ' Martin '...
  • Assigning Two Unique Random Numbers in PowerShell

    If you need to get two random numbers from a given numeric range, and you want to make sure they cannot be the same, simply tell Get-Random to pick two numbers, and assign them to two different variables at the same time: $foreground , $background = Get...
  • Eliminating Empty Text in PowerShell

    If you wanted to exclude results with empty (text) columns, you can filter based on $null values. This will get you all processes with a valid company information: Get-Process | Where-Object { $_ . Company -ne $null } | Select-Object Name , Company ,...
  • Adding Personal Drives in PowerShell

    In a previous tip we showed you how you can add new drives to easily access your desktop, your cookies or media like music and video. However, when you call that code from within a function, your new drives are gone right after you created them: function...
  • When to Use Select-Object's -ExpandProperty in PowerShell

    Use Select-Object to determine which information in a result you are interested in. Here are three easy rules for its parameters: Use -Property * when you want to see maximum information: Get-Process | Select-Object -Property * Use -Property a,b,c to...
  • Find WMI Classes with PowerShell

    In a previous tip we showed how Get-WmiObject can search for WMI class names. Some of the returned WMI class names aren't particularly useful, though, because they are used internally. You can improve search results though by excluding any class that...
  • Finding Files Only or Folders Only

    In PowerShell v2, to list only files or only folders you had to do filtering yourself: Get-ChildItem $env:windir | Where-Object { $_ . PSIsContainer -eq $true } Get-ChildItem $env:windir | Where-Object { $_ . PSIsContainer -eq $false } In PowerShell v3...
  • Export-Csv with Append

    Finally, in PowerShell v3 the cmdlet Export-Csv got a new parameter called -Append! Now you can easily append information to an existing CSV file. Have a look: Get-Process | Export-Csv $env:temp\list.csv -UseCulture -NoTypeInformation -Encoding UTF8 Get...
« First ... < Previous 58 59 60 61 62 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.