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
  • Alias
  • Parameter Names
  • Splitting Hairs
  • URL Shortener
  • Bitly
  • ShortURL
  • Domain Forwarding
  • Sponsor
  1. Guides
  2. PSCloudScript

Command Shortening

22.1.16

Ok, so now you have your PowerShell file in the cloud, but you have a 156 character command, how can this be shortened?

Invoke-Expression -Command (Invoke-RestMethod -Uri 'https://gist.githubusercontent.com/OSDeploy/30dc8839e8972493be1a343d509f423f/raw/live.osdcloud.com.ps1')

Alias

Start by using the PowerShell alias iex to replace Invoke-Expression, and irm instead of Invoke-RestMethod. Now you are down to 128 characters

iex -Command (irm -Uri 'https://gist.githubusercontent.com/OSDeploy/30dc8839e8972493be1a343d509f423f/raw/live.osdcloud.com.ps1')

Parameter Names

You can leave off the mandatory parameter names for iex and irm to trim down to 114 characters

iex (irm 'https://gist.githubusercontent.com/OSDeploy/30dc8839e8972493be1a343d509f423f/raw/live.osdcloud.com.ps1')

Splitting Hairs

Finally, you can lose the quotes around the URL if you don't have any special characters and possibly https://, but that won't recover much. You can also change replace the parenthesis with a pipe to iex, which gets you to 104, but that's still too long

irm gist.githubusercontent.com/OSDeploy/30dc8839e8972493be1a343d509f423f/raw/live.osdcloud.com.ps1 | iex

URL Shortener

Another option is to use a URL Shortener service, but make sure you test it first as there are no guarantees this will work. The following two have been tested and work fine

Bitly

ShortURL

Domain Forwarding

One benefit of using GitHub Raw links is that the MIME information is presented as Text. If you are linking to another source, you may be prompted to download the ps1 file rather than viewing the text

This makes it very easy to use in OSDCloud

Sponsor

PreviousContent-Type | Azure Static Web AppNextAzure Key Vault Secret

Last updated 3 years ago

Another option you can try is to do Domain Forwarding. This won't work with all hosts, but you may be able to redirect a subdomain if your DNS Host supports this. I use for and they make it very easy to do this in their Admin Console

This quickly allows me to get to my PSCloudScript by simply going to

OSDeploy is sponsored by and their Systems Management Tools

Google Domains
OSDCloud.com
live.osdcloud.com
Recast Software
Bitly | Custom URL Shortener, Link Management & Branded LinksBitly
Logo
ShortURL - URL Shortener
Logo
HomeRecast Software
Sponsored by Recast Software
Logo