User Tools

Site Tools


powershell

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
powershell [2021/12/31 14:31]
val [Список установленного ПО]
powershell [2023/03/17 20:42] (current)
val [Добавление в домен пользователей]
Line 14: Line 14:
  
 ===== Добавление в домен пользователей ===== ===== Добавление в домен пользователей =====
 +
 +  * [[https://​learn.microsoft.com/​en-us/​powershell/​module/​activedirectory/​new-aduser?​view=windowsserver2022-ps|New-ADUser]]
  
 <​code>​ <​code>​
 New-ADUser -Name "Ivan I. Ivanov"​ -DisplayName "Ivan I. Ivanov"​ -GivenName "​Ivan"​ -Initials "​I"​ -Surname "​Ivanov"​ ` New-ADUser -Name "Ivan I. Ivanov"​ -DisplayName "Ivan I. Ivanov"​ -GivenName "​Ivan"​ -Initials "​I"​ -Surname "​Ivanov"​ `
--SamAccountName "​user1" ​-UserPrincipalName "​user1@corpX.un"​ -Path "​CN=Users,​DC=corpX,​DC=un"​ ` +-SamAccountName "​user1"​ -AccountPassword(ConvertTo-SecureString -AsPlainText '​Pa$$w0rd1'​ -Force) `
--AccountPassword(ConvertTo-SecureString -AsPlainText '​Pa$$w0rd1'​ -Force) `+
 -Enabled $true -ChangePasswordAtLogon $false -Enabled $true -ChangePasswordAtLogon $false
  
 New-ADUser -Name "Petr P. Petrov"​ -DisplayName "Petr P. Petrov"​ -GivenName "​Petr"​ -Initials "​P"​ -Surname "​Petrov"​ ` New-ADUser -Name "Petr P. Petrov"​ -DisplayName "Petr P. Petrov"​ -GivenName "​Petr"​ -Initials "​P"​ -Surname "​Petrov"​ `
--SamAccountName "​user2" ​-UserPrincipalName "​user2@corpX.un"​ -Path "​CN=Users,​DC=corpX,​DC=un"​ ` +-SamAccountName "​user2"​ -AccountPassword(ConvertTo-SecureString -AsPlainText '​Pa$$w0rd2'​ -Force) `
--AccountPassword(ConvertTo-SecureString -AsPlainText '​Pa$$w0rd2'​ -Force) `+
 -Enabled $true -ChangePasswordAtLogon $false -Enabled $true -ChangePasswordAtLogon $false
 </​code>​ </​code>​
 +  * [[Материалы по Windows#​Установка русского Language pack в Windows Server 2016]]
 +  * [[https://​www.alitajran.com/​create-active-directory-users-from-csv-with-powershell/​|Create Active Directory Users from CSV with PowerShell]]
 +<​code>​
 +PS C:\> notepad C:​\NewUsersFinal.csv ​   !!!UTF-8
 +</​code><​code>​
 +FirstName;​Initials;​Lastname;​Username;​Email;​Password;​Telephone
 +Petr;​P;​Petrov;​user2;​user2@corp13.un;​Pa$$w0rd2;​402
 +Сидор;​С;​Сидоров;​user3;​user3@corp13.un;​Pa$$w0rd3;​403
 +</​code><​code>​
 +PS C:\> notepad C:​\Add-NewUsers.ps1
 +</​code><​code>​
 +Import-Module ActiveDirectory
 +  ​
 +$ADUsers = Import-Csv C:​\NewUsersFinal.csv -Delimiter ";"​
 +
 +foreach ($User in $ADUsers) {
 +
 +    #Read user data from each field in each row and assign the data to a variable as below
 +    $username = $User.username
 +    $password = $User.password
 +    $firstname = $User.firstname
 +    $lastname = $User.lastname
 +    $initials = $User.initials
 +    $email = $User.email
 +    $telephone = $User.telephone
 +
 +    New-ADUser `
 +            -SamAccountName $username `
 +            -Name "​$firstname $initials. $lastname"​ `
 +            -GivenName $firstname `
 +            -Surname $lastname `
 +            -Initials $initials `
 +            -Enabled $True `
 +            -DisplayName "​$firstname $initials. $lastname"​ `
 +            -OfficePhone $telephone `
 +            -EmailAddress $email `
 +            -AccountPassword (ConvertTo-secureString $password -AsPlainText -Force) -ChangePasswordAtLogon $False
 +
 +}
 +</​code><​code>​
 +PS C:\> C:​\Add-NewUsers.ps1
 +</​code>​
 +
  
 ===== Список установленного ПО ===== ===== Список установленного ПО =====
Line 36: Line 79:
 powershell -Command Get-ChildItem HKLM:​\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall powershell -Command Get-ChildItem HKLM:​\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
  
-  или+  или, с форматированием 
 + 
 +powershell -command "​Get-ItemProperty HKLM:​\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName,​ DisplayVersion,​ Publisher, EstimatedSize,​ InstallDate | Format-Table -AutoSize"​  
 + 
 +powershell -command "​Get-ItemProperty HKLM:​\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName,​ DisplayVersion,​ Publisher, EstimatedSize,​ InstallDate | Format-Table -AutoSize"​
  
-powershell -command "​Get-ItemProperty HKLM:​\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion,​ Publisher, Size, InstallDate ​| Format-Table -AutoSize" ​+  или еще 2 варианта:​) 
 +   
 +powershell -command "​Get-ItemProperty HKLM:​\Software\Microsoft\Windows\CurrentVersion\Uninstall\* ​| Get-ItemProperty | Where-Object '​DisplayName'​ | Sort-Object -Property DisplayName ​| Select-Object ​-Property ​DisplayName | Format-Table -AutoSize ​-HideTableHeaders"​ 
 +powershell -command "​Get-ItemProperty HKLM:​\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Get-ItemProperty | Where-Object '​DisplayName'​ | Sort-Object -Property DisplayName | Select-Object -Property DisplayName | Format-Table -AutoSize -HideTableHeaders"
  
-powershell -command "​Get-ItemProperty HKLM:​\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName,​ DisplayVersion,​ Publisher, ​Size, InstallDate | Format-Table -AutoSize"​+powershell -command "​Get-ItemProperty HKLM:​\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Get-ItemProperty | Where-Object '​DisplayName'​ | Sort-Object -Property DisplayName | Select-Object DisplayName,​ DisplayVersion,​ Publisher, EstimatedSize,​ InstallDate | Format-Table -AutoSize"​ 
 +powershell -command "​Get-ItemProperty HKLM:​\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* ​| Get-ItemProperty | Where-Object '​DisplayName'​ | Sort-Object -Property DisplayName ​| Select-Object DisplayName,​ DisplayVersion,​ Publisher, ​EstimatedSize, InstallDate | Format-Table -AutoSize"​
 </​code>​ </​code>​
  
powershell.1640950313.txt.gz · Last modified: 2021/12/31 14:31 by val