Wednesday, April 11, 2012

PowerShell: Replace (String)

Here's a simple thing in PowerShell and I guess most people already know how to replace strings. I had to come up with an idea on how to replace a piece of information in a domain address.

Here's the little script:

cls
$web = Get-SPWeb "YourWeb"
$httpURL = $web.Url
$httpsURL = $httpURL | foreach{$_ -replace "http", "https"}
$httpsURL

I simply take the "SPWeb" and search for "http". Everytime I get a "http" I will replace it with a "https". It's that simple.

No comments:

Post a Comment