Hello,
i have an issue with this Powershell commands:
#var1
$Username = 'rdv\miguser'
$pass = ConvertTo-SecureString -AsPlainText abcde -Force
$Credential = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
invoke-command -computername target -scriptblock {mkdir E:\BambooScripts\prod\test4} -Credential $Credential
Enable-PSRemoting
#var2
#Variables to store the username and password for the alternate account
$SPFarmAccountName = "rdv\myuser";
$SPFarmAccountName = "myuser";
$FarmAccountPassword = "mypwd";
#Convert the plain text password to a SecureString, required to create the PSCredential object
$FarmAccountPasswordAsSecureString = $FarmAccountPassword | ConvertTo-SecureString -Force -AsPlainText
#Create the PSCredential object using the alternate users username and password
#Note that the Domain name has been prepended to the username, using the $env:userdomain variable, which represents the current domain.
$credential = New-Object System.Management.Automation.PsCredential("$env:userdomain\$SPFarmAccountName",$FarmAccountPasswordAsSecureString)
#Create a new PowerShell session in the security context of the alternate user, using the PSCredential object we just created
$farmSvcAccSession = New-PSSession -Credential $credential -computername target ;
#Pass the PSSession object to Invoke-Command, and write some text to the PowerShell Window, that prints the username from the current context of the PSSession object (which will be the security context of the alternate user)
Invoke-Command -computername target -Session $farmSvcAccSession -Script { mkdir E:\BambooScripts\prod\test7 }
Invoke-Command -Session $farmSvcAccSession -Script { mkdir E:\BambooScripts\prod\test7 }
This code creates the test-Folder. However, a local admin is set as the owner. As a result, I get authorization problems later. Can someone help?
Cheers Falk
i have an issue with this Powershell commands:
#var1
$Username = 'rdv\miguser'
$pass = ConvertTo-SecureString -AsPlainText abcde -Force
$Credential = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
invoke-command -computername target -scriptblock {mkdir E:\BambooScripts\prod\test4} -Credential $Credential
Enable-PSRemoting
#var2
#Variables to store the username and password for the alternate account
$SPFarmAccountName = "rdv\myuser";
$SPFarmAccountName = "myuser";
$FarmAccountPassword = "mypwd";
#Convert the plain text password to a SecureString, required to create the PSCredential object
$FarmAccountPasswordAsSecureString = $FarmAccountPassword | ConvertTo-SecureString -Force -AsPlainText
#Create the PSCredential object using the alternate users username and password
#Note that the Domain name has been prepended to the username, using the $env:userdomain variable, which represents the current domain.
$credential = New-Object System.Management.Automation.PsCredential("$env:userdomain\$SPFarmAccountName",$FarmAccountPasswordAsSecureString)
#Create a new PowerShell session in the security context of the alternate user, using the PSCredential object we just created
$farmSvcAccSession = New-PSSession -Credential $credential -computername target ;
#Pass the PSSession object to Invoke-Command, and write some text to the PowerShell Window, that prints the username from the current context of the PSSession object (which will be the security context of the alternate user)
Invoke-Command -computername target -Session $farmSvcAccSession -Script { mkdir E:\BambooScripts\prod\test7 }
Invoke-Command -Session $farmSvcAccSession -Script { mkdir E:\BambooScripts\prod\test7 }
This code creates the test-Folder. However, a local admin is set as the owner. As a result, I get authorization problems later. Can someone help?
Cheers Falk