> For the complete documentation index, see [llms.txt](https://www.osdeploy.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.osdeploy.com/guides/pscloudscript/command-shortening.md).

# Command Shortening

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

```powershell
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

```powershell
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

```powershell
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

```powershell
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

{% embed url="<https://bitly.com>" %}

![](/files/L7SXPzSBVhs043yZYXon)

### ShortURL

{% embed url="<https://www.shorturl.at>" %}

![](/files/3Jk0DqklTUnLICQgtg0H)

## Domain Forwarding

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 [Google Domains](https://domains.google.com/registrar/) for [OSDCloud.com](https://osdcloud.osdeploy.com/) and they make it very easy to do this in their Admin Console

![](/files/Kc1hb0WTpMsDH4MkbeMy)

This quickly allows me to get to my PSCloudScript by simply going to [live.osdcloud.com](http://live.osdcloud.com/)

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

![](/files/S7GAmubgktaXuETDco3v)

This makes it very easy to use in **OSDCloud**

![](/files/Q5TF1Ds5Lq4CggUyEmFw)

## Sponsor

OSDeploy is sponsored by [Recast Software](https://www.recastsoftware.com/?utm_source=osdeploy\&utm_medium=ad\&utm_campaign=web) and their Systems Management Tools

{% embed url="<https://www.recastsoftware.com/?utm_source=osdeploy&utm_medium=ad&utm_campaign=web>" %}
Sponsored by Recast Software
{% endembed %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.osdeploy.com/guides/pscloudscript/command-shortening.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
