Skip to content

encode urls using dot.net classes in powershell

2012/01/03

Spaces become +

for query strings after the ?

[System.Reflection.Assembly]::LoadWithPartialName(“System.Web”) | out-null
[System.Web.HttpUtility]::UrlEncode(“folder with space”)

convert the special chars to %…

[system.uri]::EscapeDataString($MyUrl)

 

This is what you need for multiline text when you add , update sharepoint List items:

[System.Web.HttpUtility]::HtmlEncode($htmltext)

Advertisements

From → powershell, strings

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: