Question Informations Script PS.

Plus d'informations
il y a 8 ans 5 mois #24698 par xyz
Réponse de xyz sur le sujet Re:Informations Script PS.
ShizuCorporation écrit:

Est-ce plus clair ?

Oui je pense.
Avant de chercher à modifier ton script, recherche comment associer une imprimante à un compte AD, si c'est bien ce que tu veux faire.
Comme j'administre peu l'AD, je ne suis pas le mieux placer pour t'aider. Mais avec tes infos complémentaires d'autres pourront maintenant le faire.

Tutoriels PowerShell

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

Plus d'informations
il y a 8 ans 5 mois #24699 par ShizuCorp
Réponse de ShizuCorp sur le sujet Re:Informations Script PS.
D'accord merci, après je ne cherche pas forcement avec une imprimante. Cela peut-être une tablette, un téléphone ect...

Merci de ta réponse!

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

Plus d'informations
il y a 8 ans 5 mois #24701 par ShizuCorp
Réponse de ShizuCorp sur le sujet Re:Informations Script PS.
:dry:<br><br>Message édité par: ShizuCorporation, à: 15/12/17 15:26

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

Plus d'informations
il y a 8 ans 5 mois #24702 par ShizuCorp
Réponse de ShizuCorp sur le sujet Re:Informations Script PS.
Depuis le week-end, personnes ne serait au courant?

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

Plus d'informations
il y a 8 ans 5 mois #24703 par ShizuCorp
Réponse de ShizuCorp sur le sujet Re:Informations Script PS.
Puis-je me servir d'un script comme celui-ci pour mes ajouts d'imprimantes/téléphones/tablettes et autres ?

[code:1]
param (
[Parameter(Mandatory, ValueFromPipelineByPropertyname)]
[ValidateNotNullOrEmpty()]
[string]$FirstName,

[Parameter(Mandatory, ValueFromPipelineByPropertyname)]
[ValidateNotNullOrEmpty()]
[string]$LastName,

[Parameter(Mandatory, ValueFromPipelineByPropertyname)]
[ValidateNotNullOrEmpty()]
[string]$MiddleInitial,

[Parameter(Mandatory, ValueFromPipelineByPropertyname)]
[ValidateNotNullOrEmpty()]
[string]$Department,

[Parameter(Mandatory, ValueFromPipelineByPropertyname)]
[ValidateNotNullOrEmpty()]
[string]$Title,

[Parameter(Mandatory, ValueFromPipelineByPropertyname)]
[ValidateNotNullOrEmpty()]
[string]$Imprimante,

[Parameter(Mandatory, ValueFromPipelineByPropertyname)]
[ValidateNotNullOrEmpty()]
[string]$Téléphones,

[Parameter(Mandatory, ValueFromPipelineByPropertyname)]
[ValidateNotNullOrEmpty()]
[string]$Tablettes,
[/code:1]

Je l'ai trouver sur Internet, sans aucunes modifications il ressemble à ceci, est-il utilisable pour mon besoin? Ou me conseillez-vous de ne pas le prendre pour mon besoin actuel ?

[code:1]
param (
[Parameter(Mandatory, ValueFromPipelineByPropertyname)]
[ValidateNotNullOrEmpty()]
[string]$FirstName,

[Parameter(Mandatory, ValueFromPipelineByPropertyname)]
[ValidateNotNullOrEmpty()]
[string]$LastName,

[Parameter(Mandatory, ValueFromPipelineByPropertyname)]
[ValidateNotNullOrEmpty()]
[string]$MiddleInitial,

[Parameter(Mandatory, ValueFromPipelineByPropertyname)]
[ValidateNotNullOrEmpty()]
[string]$Department,

[Parameter(Mandatory, ValueFromPipelineByPropertyname)]
[ValidateNotNullOrEmpty()]
[string]$Title,

[Parameter(ValueFromPipelineByPropertyname)]
[ValidateNotNullOrEmpty()]
[string]$Location = 'OU=Corporate Users',

[Parameter()]
[ValidateNotNullOrEmpty()]
[string]$DefaultGroup = 'Entreprise01',

[Parameter()]
[ValidateNotNullOrEmpty()]
[string]$DefaultPassword = 'Password01',

[Parameter()]
[ValidateScript({ Test-Path -Path $_ })]
[string]$BaseHomeFolderPath = '\\MEMBERSRV1\Users'
)

## Find the distinguished name of the domain the current computer is a part of.
$DomainDn = (Get-AdDomain).DistinguishedName
## Define the 'standard' username (first initial and last name)
$Username = \&quot;$($FirstName.SubString(0, 1))$LastName\&quot;

#region Check if an existing user already has the first initial/last name username taken
Write-Verbose -Message \&quot;Checking if [$($Username)] is available\&quot;
if (Get-ADUser -Filter \&quot;Name -eq '$Username'\&quot;«»)
{
Write-Warning -Message \&quot;The username [$($Username)] is not available. Checking alternate...\&quot;
## If so, check to see if the first initial/middle initial/last name is taken.
$Username = \&quot;$($FirstName.SubString(0, 1))$MiddleInitial$LastName\&quot;
if (Get-ADUser -Filter \&quot;Name -eq '$Username'\&quot;«»)
{
throw \&quot;No acceptable username schema could be created\&quot;
}
else
{
Write-Verbose -Message \&quot;The alternate username [$($Username)] is available.\&quot;
}
}
else
{
Write-Verbose -Message \&quot;The username [$($Username)] is available\&quot;
}
#endregion

#region Ensure the OU the user's going into exists
$ouDN = \&quot;$Location,$DomainDn\&quot;
if (-not (Get-ADOrganizationalUnit -Filter \&quot;DistinguishedName -eq '$ouDN'\&quot;«»))
{
throw \&quot;The user OU [$($ouDN)] does not exist. Can't add a user there\&quot;
}
#endregion

#region Ensure the group the user's going into exists
if (-not (Get-ADGroup -Filter \&quot;Name -eq '$DefaultGroup'\&quot;«»))
{
throw \&quot;The group [$($DefaultGroup)] does not exist. Can't add the user into this group.\&quot;
}
if (-not (Get-ADGroup -Filter \&quot;Name -eq '$Department'\&quot;«»))
{
throw \&quot;The group [$($Department)] does not exist. Can't add the user to this group.\&quot;
}
#endregion

#region Ensure the home folder to create doesn't already exist
$homeFolderPath = \&quot;$BaseHomeFolderPath\$UserName\&quot;
if (Test-Path -Path $homeFolderPath)
{
throw \&quot;The home folder path [$homeFolderPath] already exists.\&quot;
}
#endregion

#region Create the new user
$NewUserParams = @{
'UserPrincipalName' = $Username
'Name' = $Username
'GivenName' = $FirstName
'Surname' = $LastName
'Title' = $Title
'Department' = $Department
'SamAccountName' = $Username
'AccountPassword' = (ConvertTo-SecureString $DefaultPassword -AsPlainText -Force)
'Enabled' = $true
'Initials' = $MiddleInitial
'Path' = \&quot;$Location,$DomainDn\&quot;
'ChangePasswordAtLogon' = $true
}
Write-Verbose -Message \&quot;Creating the new user account [$($Username)] in OU [$($ouDN)]\&quot;
New-AdUser @NewUserParams
#endregion

#region Add user to groups
Write-Verbose -Message \&quot;Adding the user account [$($Username)] to the group [$($DefaultGroup)]\&quot;
Add-ADGroupMember -Members $Username -Identity $DefaultGroup
Write-Verbose -Message \&quot;Adding the user account [$($Username)] to the group [$($Department)]\&quot;
Add-ADGroupMember -Members $Username -Identity $Department
#endregion

#region Create the home folder
Write-Verbose -message \&quot;Creating the home folder [$homeFolderPath]...\&quot;
$null = mkdir $homeFolderPath
#endregion
[/code:1]<br><br>Message édité par: ShizuCorporation, à: 18/12/17 11:18

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

Plus d'informations
il y a 8 ans 5 mois #24710 par Philippe
Réponse de Philippe sur le sujet Re:Informations Script PS.
salut ShizuCorporation

Puis-je me servir d'un script comme celui-ci pour mes ajouts d'imprimantes/téléphones/tablettes et autres ?

oui si tu comprend ce que fais le script

Je l'ai trouver sur Internet, sans aucunes modifications il ressemble à ceci, est-il utilisable pour mon besoin?

ce script repond a un besoin : ajout d'un compte utilisateur dans l'AD dans une OU et deux groupes donnais en paramètre

Ou me conseillez-vous de ne pas le prendre pour mon besoin actuel ?

ça depend si je comprend ce qui suis :

Pour cela ils remplissent le tableau, qui ensuite je transforme en CSV, cependant, comment les informations ou y'a écrit : Imprimante, tablette, téléphone ect peuvent être retranscrite sur le script, car c'est bien beau de l'avoir sur CSV mais c'est le script qui permet d'ajouter cela dans les infos de création de comptes !

si je comprend cette demande tu ajoute les infos d'Imprimante, tablette, téléphone, etc, dans le compte utilisateur,
le script trouvé ne contient pas ces infos

j'ai une question : comment fais tu actuellement pour ajouter ces infos dans l'AD, manuellement je suppose mais dans quel partie de l'AD, dans quel groupe, crée tu de nouveaux compte pour les Imprimante, tablette, téléphone, etc ?
a partir de cette réponse on pourra t'aidée dans la réalisation de ton script !

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

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