Power Tips

Share |

Join PowerShell.com!
Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Award-winning PowerShellPlus


Admin Guide to PowerShell Remoting


Mastering PowerShell eBook

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
  • Determining Function Parameters Supplied by User

    To find out which parameters that a user submitted to a self-defined function, you can use $PSCmdlet like this: function Get-Parameters { [CmdletBinding()] param ( $name , $surname = "Default" , $age , $id ) $PSCmdlet . MyInvocation.BoundParameters...
  • Re-Running Your Profile

    If you made changes to your profile script and want to see the changes that are in effect without having to close and restart PowerShell, you can simply run your profile script dot-sourced: . $profile However, you may receive (harmless) exceptions this...
  • Create (and Edit) your Profile Script

    Profile scripts are automatically executed whenever PowerShell launches. Your profile script is the perfect place to customize your PowerShell environment, change the prompt, colors, and make any changes you would like to keep in all of your sessions...
  • Enter-PSSession - Do's and Dont's

    Enter-PSSession will let you switch your console input to a remote computer—if remoting is enabled on the target computer. Essentially, anything you enter after Enter-PSSession is sent to the remote computer that you specified with -ComputerName...
  • Get WebClient with Proxy Authentication

    If your company is using an Internet proxy, and you'd like to access Internet with a webclient object, make sure it uses the proxy and supplies your default credentials to it. You could write a little helper function to get such a pre-configured webclient...
  • Strongly Typed Arrays

    When you assign strongly typed values to an array, the type declaration will remain intact only as long as you do not add new array content: $array = [ Int []](1,2,3,4,5) $array . GetType (). FullName System.Int32 [] $array += 6 $array . GetType (). FullName...
  • Create Files and Folders in One Step

    Use New-Item like this when you want to create a file plus all the folders necessary to host the file: new-item -type file -force c:\subfolder\anothersubfolder\yetanotherone\ test1.txt This will create the necessary folders first and then insert a blank...
  • Running 32-Bit-Code on 64-Bit Machines

    Some code may not work right on 64-Bit machines. Use this approach to make PowerShell execute code in an isolated 32-Bit PowerShell session and hand over its results to your 64-Bit PowerShell: $32bitcode = { [ IntPtr ]:: Size } # run on 64bit machine...
  • Get Notification When a Background Job is Done

    When you assign long-running commands to a background session, you may want to get some notification when the job is completed so you don't have to constantly check its status. Here is how: $job = Start-Job -Name GetLogFiles { dir $env:windir * ....
  • Running Commands in the Background

    You can also transfer commands into another PowerShell session and run it in the background. This will find all log files recursively in your Windows folder and all of its sub-folders as background job: $job = Start-Job { Dir $env:windir * . log -recurse...
  • Escaping Spaces

    You should remember that spaces are special characters in PowerShell, too. They are token delimiters, and once you feed arguments to a native command, PowerShell will separate arguments by space and feed the individual arguments one by one to the native...
  • Why Native Commands Fail In PowerShell

    You probably already know that not all native commands work equally well in PowerShell. Have a look here: find / I / N "dir" * . ps1 In cmd.exe, this line finds all occurrences of "dir" in all PowerShell scripts that are located in...
  • Downloading Internet Files with Dialog

    There is a great way to download large files from the Internet. This example downloads a tutorial video from Idera that, once downloaded will run in your media player: [ reflection.assembly ]:: LoadWithPartialName ( "Microsoft.VisualBasic" ...
  • Using OpenFile Dialog

    You can use this code to open a standard OpenFile dialog in your PowerShell scripts: [ System.Reflection.Assembly ]:: LoadWithPartialName ( "System.windows.forms" ) | Out-Null $dialog = New-Object System.Windows.Forms.OpenFileDialog $dialog...
  • Finding Methods with Specific Keywords

    As such, .NET Framework is huge and full of stars, and it is not easy to discover interesting methods buried inside of it. You can use the next lines to find all methods with a given keyword: $key = 'Kill' [ System.Diagnostics.Process ]. Assembly...
« First ... < Previous 58 59 60 61 62 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.