i want to create a new sub site using power shell but by a given user as in context, how can i do this.

I am using New-SPWeb Cmdlet.

  • Can you explain your objective and clarify your question a little further...
    – BlueBird
    Oct 18, 2013 at 15:46

1 Answer 1


You could try this... although I have to warn you I've never done it before.

$username = 'DOMAIN\username'
$password = 'Pa$$word'
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))
Invoke-Command -Credential $cred -ComputerName localhost -ScriptBlock 
#Your PS Code...
New-SPWeb -url "http://server" -Template "STS#0" -Name "test99" -Description "test99" -UseParentTopNav

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.