0

I'm relatively new to PowerShell and getting my head around a script i am modifying for my environment.

Simply put, I need to add a URL as a variable to my script, but there is a space in it. I have tried replacing the space with a '%20' but it still doesn't resolve.

$WebUrl = "http://sharepoint.acceptance/xxx/xxx/xxx/xxx/xxx/Workflow History/"

and

$WebUrl = "http://sharepoint.acceptance/xxx/xxx/xxx/xxx/xxx/Workflow%20History/"

when validated with

$Web = Get-SPWeb $WebUrl -ea SilentlyContinue
if($Web -eq $null)
{
   Write-Error "The web with URL '$WebUrl' was not found, halting execution."
   break
}
else {
write-host "$WebUrl is good"
}

both return

"The web with URL 'http://sharepoint.acceptance/xxx/xxx/xxx/xxx/xxx/Workflow%20History/' was not found, halting execution." 

in each case. I'm sure what I am doing is just a matter of bad syntax but I'm just not experienced enough to see the issue.

1 Answer 1

0

I don't think the problem is the space, having a space in a web url variable is fine.

The problem seems to be that your WEB url needs to be the Website link and you're providing a link to the workflow history list.

e.g.

web url --> http://contoso.com/site1

list url --> http://contoso.com/site1/lists/workflow history

TL;DR assign $WebUrl the url for your website, not your list

1
  • 1
    Thankyou, yes i was calling one layer too deep. Commented Apr 16, 2021 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.