LogoLogo
TwitterLinkedInGitHubPowerShell Gallery
  • About
  • Events
  • Blog
    • 2022
      • 🆕OSD January Update
      • 🆕PSCloudScript Basics
    • 2021
      • Start-OOBEDeploy
      • OSDCloud
      • PowerShell Gallery in WinPE
      • BitLocker KeyProtectors
      • WindowsCapability -and WindowsPackage
      • Scheduled Tasks
        • Building a Task
        • Task Permissions
        • Task Trigger
        • Action a PowerShell File
        • Action a PS Encoded Script
        • Conclusion
          • Windows Activation and Edition Change
          • REG.exe and Multiple Actions
    • 2019
      • 2019-02
        • Offline Servicing vs Reference Image
      • 2019-04
        • Windows 10 Upgrade MultiLang (Uno)
      • 2019-06
        • Offline Servicing Windows 10 with CU for .NET 4.8
        • OSDBuilder and .NET CU KB4480056
      • 2019-09
        • Black Screen During Windows 10 Setup
      • 2019-11
        • I Hate OSDBuilder
    • 2018
      • WinPE 10 1809 WPF DLL Fix
      • Microsoft Update Releases
      • Create WinPE.wim from Boot.wim or WinRE.wim
      • Windows Setup: FAT32 USB with +4GB Install.wim
      • Windows 10 from ESD
      • Windows 10 1809 Appx Issues
      • Mount-WindowsImage -Optimize
  • Guides
    • Autopilot App Registration
    • PSCloudScript
      • PS Cmdlets
      • GitHub Gist
      • GitHub Git Repo
      • Content-Type | Azure Static Web App
      • Command Shortening
      • Azure Key Vault Secret
      • OSD PowerShell Module
      • PSCloudScript Examples
        • Autopilot
        • AutopilotOOBE
        • OSDCloud Live
        • WinPE PowerShell Gallery
        • OSDCloud WinPE and OOBE
    • go OSDCloud
      • Azure Function
      • Custom Domain
      • SSL Binding
      • Proxies
  • PowerShell
    • OSD
    • OSDCloud
    • OSDBuilder (Offline Servicing)
    • OSDSUS (Update Catalogs)
    • OSDUpdate (MS Updates)
    • OSDDrivers (Compact Drivers)
    • PShot
      • Release Notes
      • Usage
        • -Directory
        • $AutoPath
        • -Prefix
        • -Count
        • -Delay
        • -Clipboard
        • -Primary
        • The Object
      • Technical
        • Why a Module?
        • Resolution, Scale and DPI
Powered by GitBook
On this page
  • Method
  • KeyVault Secret Method
  • Content
  • Sponsor
  1. Guides

PSCloudScript

22.1.17

I'm still adding content to this guide, so please be patient

I've been spending a fair amount lately playing around with running PowerShell scripts that are saved on the internet and I thought it would be helpful to share what I have leared on this ... so this guide will be focused on executing PowerShell scripts that are saved on the Internet, what I call a PSCloudScript

Method

The method for running a PowerShell script on the internet is to get the raw content of a URL using Invoke-RestMethod, and then execute the result using Invoke-Expression

Invoke-RestMethod -Uri $Uri | Invoke-Expression

The following command lines are identical to the method above, just formatted differently. My preference is iex(irm $Uri) as it is short and works for both PowerShell and CMD with minimal effort

PowerShell
#full command
Invoke-Expression -Command (Invoke-RestMethod -Uri $Uri)

#using alias
iex(irm $Uri)

#pipeline
Invoke-RestMethod -Uri $Uri | Invoke-Expression

#pipeline using alias
irm $Uri | iex
Command Prompt
rem full command
powershell Invoke-Expression -Command (Invoke-RestMethod -Uri $Uri)

rem using alias
powershell iex(irm $Uri)

KeyVault Secret Method

I'm jumping ahead here, but here is the command line for executing a PowerShell script saved as an Azure Key Vault Secret

PowerShell
iex(AzKeyVaultSecret $VaultName $SecretName -As)

Content

Sponsor

PreviousAutopilot App RegistrationNextPS Cmdlets

Last updated 3 years ago

OSDeploy is sponsored by and their Systems Management Tools

PS Cmdlets
GitHub Gist
GitHub Git Repo
Content-Type | Azure Static Web App
Command Shortening
Azure Key Vault Secret
OSD PowerShell Module
PSCloudScript Examples
Recast Software
HomeRecast Software
Sponsored by Recast Software
Logo