When people ask me what I do in my free time, this is the short answer. It’s a never ending story.

How to execute PowerShell scrips

For all upcoming projects you have to be aware how to run them. I assume that you are familiar with execution policy and file blocking. All comments like “how to run…” will be deleted.

Most simple method to run anything with no prompts is to unblock data stream for particular file.

  • Unblock-File – Cmdlet available since PowerShell version 3.0.
  • Modify Data Stream – works for everything and everywhere. Examples:
    cmd /c echo.>myFile.ps1:Zone.Identifier – clears stream preferences
    notepad C:\myFolder\myFile.exe:Zone.Identifier – edit stream preferences in notepad

Microsoft articles about execution policy:

If PowerShell script execution is disabled on the system and you are not allowed to modify the policy, read the file as a single line string, convert the content to script block and execute it with call operator ‘&’. Example:

& ([ScriptBlock]::Create((Get-Content .\MyScript.ps1 | Out-String)))

2 thoughts on “Home

  1. Andrea Christensen

    AllSigned — You can run scripts signed by a trusted developer. With this setting in place, before executing, a script will ask you to confirm that you want to run it. Cmdlets can get data for analysis or transfer data to another cmdlet using pipes (I’ll discuss pipes more in a moment).

  2. vurtil opmer

    This is a very good tips especially to those new to blogosphere, brief and accurate information… Thanks for sharing this one. A must read article.


Leave a Reply

Your email address will not be published. Required fields are marked *