Sign up ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
    
Can you explain your objective and clarify your question a little further... – BlueBird Oct 18 '13 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
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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