SharePoint 2010 afirma la ayuda de PowerShell clásico
-
09-12-2019 - |
Pregunta
Tengo un requisito de cliente para pasar de un clásico a las reclamaciones.Actualmente estoy utilizando un poco de PowerShell de http://derekmartin.org/archives/701
$webApp =
$farm = get-SPFarm
$wa = get-SPWebApplication $webApp
$site = get-SPSite $webApp
$web = $site.OpenWeb()
foreach ($user in $web.AllUsers) {
$newuser = $user
$newuserLoginName = “”
write-host($user.LoginName)
if ($newuser.LoginName.StartsWith(“i:0#.w|”))
{
! $newuserLoginName = $user.LoginName.Substring(7)
}
$user = $newuser
$farm.MigrateUserAccount($user.LoginName, $newuserLoginName, $false)
}
Lamentablemente cada vez que trato de ejecutarlo, obtengo lo siguiente
Expresión de asignación no válida.El lado izquierdo de un operador de asignación debe ser algo que se puede asignar a gustar una variable o una propiedad. En C: \ Users \ User \ Desktop \ reclameS.PS1: 12 Char: 22 ¡+!$ newuserloginname= <<<< $ user.loginname.substring (7) + Categoryinfo: parserError: (:) [], parseException + CompletamenteQualifiedErrorid: InvalidSeFthandside
¿Alguna idea de lo que podría estar equivocado?
¡Gracias!
Perdón ¿Olvidó pegar el script en la pregunta en originalmente!
Solución
I may be wrong but I suppose that the exclamation mark on the
!$newuserLoginName = $user.LoginName.Substring(7)
line should just be a refuse (or at last it doesn't match any syntax I am aware of).
If you are on a test environment or are otherwise sure that you won't damage your system with a wrong comand, I would try to replace the if with:
if ($newuser.LoginName.StartsWith(“i:0#.w|”))
{
$newuserLoginName = $user.LoginName.Substring(7)
}
The if should simply remove the "claim specific part" from the login name, so I would assume the original blog post intended it this way.
That said, know that I have never done this before and are only trying to spot an error in the powershell code. I don't know if that code will actually do what promised, so use that at your risk (or wait some more expert other user to confirm the behaviour).