$Computername = 'xxx'
Get-CimInstance Win32_Group -filter "LocalAccount='True' and SID='S-1-5-32-555'" -ComputerName $Computername |
Select-Object PSComputername,Name,@{Name="Members";Expression={
(Get-CimAssociatedInstance -InputObject $_ -ResultClassName Win32_UserAccount).Name
}}
$Computername = 'xxx'
Get-WMIObject Win32_Group -filter "LocalAccount='True'and SID='S-1-5-32-555'" -ComputerName $Computername|
Select-Object PSComputername,Name,@{Name="Members";Expression={
$_.GetRelated("Win32_UserAccount").Name
}}
function Get-LocalGroupMember {
param(
[Parameter(ValueFromPipeline=$false, Position=0)]
[string[]]$GroupName = 'Administrators',
[Parameter(ValueFromPipeline=$true)]
[string[]]$ComputerName = '.'
)
PROCESS {
foreach ($computer in $ComputerName) {
foreach ($group in $GroupName) {
$grp = [ADSI]"WinNT://$computer/$group,group"
Write-Verbose ('Group: ' + $grp.Path) # test for existance
$members = @($grp.psbase.Invoke("Members"))
if ($members) {
$members | Foreach-Object {
$name = $_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)
$class = $_.GetType().InvokeMember("Class", 'GetProperty', $null, $_, $null)
$parent = $_.GetType().InvokeMember("Parent", 'GetProperty', $null, $_, $null) -replace 'WinNT://' -replace '.*/'
'' | Select-Object @{n='Class';e={$class}},@{n='Domain';e={$parent}},@{n='Name';e={$name}}
}
}
}
}
}
}
Get-LocalGroupMember -ComputerName MySuperServer -GroupName 'Пользователи удаленного рабочего стола', 'Remote Desktop Users'
$Paths = $Paths.FullName
foreach ( $Newpath in $Path)
?-Exclude *.xl*
тоже странно, проще проверить на xl* в коде, чем заставлять этим заниматься move-item. Может быть, вы ps заставляете по новой весь каталог обшаривать таким образом, а в нём 10000 файлов xls$referenceUser = Get-ADUser refuser -Property userParameters
Set-ADUser targetUser -Replace @{
userParameters = $referenceUser.userParameters
}
$ar = New-Object System.Security.AccessControl.FileSystemAccessRule($group, @('Read', 'ReadAndExecute'),
'ContainerInherit,ObjectInherit', 'None', 'Allow')
# Получаете список папок
Get-ChildItem -Directory -Recurse $Path | Foreach-Object {
# Получаете по ним ACL
$acl = $_.GetAccessControl('Access')
# Сравниваете с нужным
if (-not ($acl.Access.IdentityReference -eq $group)) {
# Добавляете если надо
$acl.SetAccessRule($ar)
$_.SetAccessControl($acl)
}
}
$u = Get-ADUser iivanov
$u2 = [ADSI]("LDAP://" + $u.DistinguishedName)
$u2.SetPassword('PassWord123')
$PathIn = "\\Server\files"
Get-ChildItem -Path $PathIn -Filter UVHD-S*.vhdx | Where-Object {
$User = Get-AUser $_.BaseName.Substring(5);
$User.Enabled -eq $false
} | Remove-Item -Whatif
$User.Enabled -eq $false
Start-Process helloworld.exe
From the ntstatus.h SDK header file:
//
// MessageId: STATUS_DLL_NOT_FOUND
//
// MessageText:
//
// The program can't start because %hs is missing from your computer.
// Try reinstalling the program to fix this problem.
//
#define STATUS_DLL_NOT_FOUND ((NTSTATUS)0xC0000135L) // winnt
Get-ADUser IIvanov -prop AccountExpirationDate, accountExpires
AccountExpirationDate : 05.10.2022 0:00:00
accountExpires : 133093908000000000
# Как делаете вы
Get-Date 133093908000000000 -UFormat '%Y.%m.%d'
0422.10.04
# Что там на самом деле вы должны были увидеть
Get-Date 133093908000000000
4 октября 0422 г. 21:00:00
# Как делаю я
[datetime]::FromFileTime(133093908000000000)
5 октября 2022 г. 0:00:00
# Что великолепно совпадает с AccountExpirationDate, который я и рекомендую
robocopy \\%computername%\c$\logs \\server\logs\%computername%\logs /e
$computers =get-content 'c:\computers.txt'
foreach ($computername in $computers) {
robocopy "\\$computername\c`$\logs" "\\server\logs\$computername\logs" /e
}
for /f %%a in (c:\computers.txt) do robocopy \\%%a\c`$\logs \\server\logs\%%a\logs /e
[System.BitConverter]::ToSingle(@(0xcd,0xcc,0x4c,0x41),0)
12,8
$usb = Get-ChildItem -path HKLM:\SYSTEM\ControlSet001\Enum\USB\ -Recurse
$usb | Where-Object { $_.GetValue('Address') -eq 4 }
$usb[1].<Ctrl+Space>
Get-Member -InputObject $usb[1]
$x = 'test'
psexec \\server powershell -NoProfile -Сommand "write-host '$X'"
psexec \\server powershell -NoProfile -Command "param(`$a) write-host `$a" $x
New-ItemProperty -LiteralPath HKCR:\Microsoft.PowerShellScript.1\Shell\runas\command -Name '(Default)' -Value 'powershell.exe -NoExit -Command "if((Get-ExecutionPolicy ) -ne ''AllSigned'') { Set-ExecutionPolicy -Scope Process Bypass }; & ''%1''"' -PropertyType String -Force | Out-Null;
Invoke-Command -ComputerName $computer { C:\Temp\Install.exe /S }
$session = New-PSSession -ComputerName $computer
Invoke-Command -Session $session { C:\Temp\Install.exe /S }
Invoke-Command -Session $session { C:\Temp\Install2.exe /S }