Question Personnalisation du profil

Plus d'informations
il y a 14 ans 1 semaine #6512 par Granier
Personnalisation du profil a été créé par Granier
Bonjour

J'essaye votre script du livre dans le chapitre \"personnalisation du profil\" paragraphe 4 \"creation du profil\" et j'ai une erreur sur la commande :

[code:1]$principal = new-object System.Security.principal.windowsprincipal [/code:1]

le shell me renvoie l'erreur suivante:

[code:1]New-Object : Constructeur introuvable. Impossible de trouver un constructeur approprié pour le type System.Security.pri
ncipal.windowsprincipal.
Au niveau de C:\Users\tgranier\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 : 20 Caractère : 24
+ $principal = new-object <<<< System.Security.principal.windowsprincipal
+ CategoryInfo : ObjectNotFound: (:«») [New-Object], PSArgumentException
+ FullyQualifiedErrorId : CannotFindAppropriateCtor,Microsoft.PowerShell.Commands.NewObjectCommand[/code:1]

Pouvez-vous m'aider SVP ?

Merci d'avance

Thierry<br><br>Message édité par: Arnaud, à: 13/04/10 08:38

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 14 ans 6 jours #6513 par Arnaud Petitjean
Bonjour Thierry,

Si tu regardes bien le message d'erreur retourné (si si je te le conseille car on y trouve plein de choses intéressantes ;) ), il manque un constructeur.

Autrement dit, il faut que tu utilises la syntaxe suivante :

[code:1]$principal = new-object System.Security.principal.windowsprincipal($currentuser)[/code:1]

En ayant bien sûr pris soin au préalable de donner une valeur à la variable $currentuser.

Soit le code suivant :
[code:1]
$currentuser=[system.security.principal.windowsidentity]::getcurrent()
$principal = new-object System.Security.principal.windowsprincipal($currentuser)
[/code:1]

Arnaud

MVP PowerShell et créateur de ce magnifique forum :-)
Auteur de 6 livres PowerShell aux éditions ENI
Fondateur de la société Start-Scripting
Besoin d'une formation PowerShell ?

Connexion ou Créer un compte pour participer à la conversation.

Temps de génération de la page : 0.067 secondes
Propulsé par Kunena