Пользователи в PowerShell

Содержание
Получить текущего пользователя
Список пользователей
Список администраторов
Создать пользователя
Сделать пользователя администратором
Похожие статьи

Получить текущего пользователя

Текущего пользователя можно получить командой

$Env:Username

Andrei

Список пользователей

Список локальных пользователей

Get-LocalUser

Name Enabled Description ---- ------- ----------- Administrator False Built-in account for administering the computer/domain DefaultAccount False A user account managed by the system. defaultuser0 False LAPTOP123-ANDREI True RmAdmin True Guest False Built-in account for guest access to the computer/domain WDAGUtilityAccount False A user account managed and used by the system for Windows Defender Application Guard scenar…

Список администраторов

Список админов

Get-LocalGroupMember -Group "Administrators"

ObjectClass Name PrincipalSource ----------- ---- --------------- Group ACCDOM\Domain Admins ActiveDirectory User LAPTOP123\Administrator Local User LAPTOP123\LAPTOP123-ANDREI Local

Создать пользователя

$Password = Read-Host -AsSecureString

Введите пароль и нажмите Enter

New-LocalUser "andrei" -Password $Password -FullName "eth1.ru" -Description "Second Admin"

Убедитесь, что новый пользователь теперь в списке

Get-LocalUser

Name Enabled Description ---- ------- ----------- Administrator False Built-in account for administering the computer/domain andrei True Second Admin DefaultAccount False A user account managed by the system. defaultuser0 False LAPTOP123-ANDREI True RmAdmin True Guest False Built-in account for guest access to the computer/domain WDAGUtilityAccount False A user account managed and used by the system for Windows Defender Application Guard scenar…

Сделать пользователя администратором

Add-LocalGroupMember -Group "Administrators" -Member "andrei"

Права доступа

PS C:\Users\AO> notepad permissions.txt
PS C:\Users\AO> Get-Acl -Path "C:\Users\AO\permissions.txt"

Directory: C:\Users\AO\sandbox\powershell Path Owner Access ---- ----- ------ permissions.txt AzureAD\AO NT AUTHORITY\SYSTEM Allow FullControl…

Article author: Andrei Olegovich

Похожие статьи
Windows
PowerShell
Посмотреть конец файла в PowerShell (аналог tail)
Создать новый файл в PowerShell (аналог touch)
Проверить контрольную сумму файла в PowerShell (аналог md5sum)

Search this site

Subscribe to Telegram channel @aofeed to follow new articles and updates to old ones

Go to channel

@aofeed

Ask a question in the Telegram group

@aofeedchat

Contacts and cooperation:
I recommend our hosting beget.ru
Write to info@urn.su if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: