$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
- name: Install the version '1.00' of package "foo"
ansible.builtin.apt:
name: foo=1.00
- name: postgresql status
command: systemctl status postgresql
register: p_status
- debug: var=p_status
- name: ensure postgresqt restarted
systemctl:
name: postgresql
state: restarted
- name: Create a symbolic link
ansible.builtin.file:
src: /file/to/link/to
dest: /path/to/symlink
owner: foo
group: foo
state: link
---
- hosts: localhost
gather_facts: no
handlers:
- name: restart something
debug: msg="Something restarted"
tasks:
- debug: msg="Special action"
changed_when: true
notify: restart something
role1
meta dependencies subrole
role2
meta dependencies subrole
subrole
handlers
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