Skip to content

Latest commit

 

History

History
83 lines (59 loc) · 1.9 KB

Windows.md

File metadata and controls

83 lines (59 loc) · 1.9 KB

Windows

BAT

Dodawanie PATH tymczasowo

set PATH=c:\sciezka;%PATH%

PowerShell

Escapowanie cudzysłowia

`"

Włączenie konta

Enable-LocalUser -Name "Administrator"

albo

Get-LocalUser -Name "Administrator" | Enable-LocalUser

Tworzenie usług

Do tworzenia usług używane jest NSSM

$serviceName = 'service-name'
$serviceDir = 'c:\service-home'

nssm install $serviceName 'c:\absolute\path\to\service.exe'
nssm set $serviceName AppParameters "-some -additional -params"
nssm set $serviceName AppDirectory $serviceDir
nssm set $serviceName AppExit Default Restart
nssm set $serviceName AppStdout "$serviceDir\$serviceName.log"
nssm set $serviceName AppStderr "$serviceDir\$serviceName.error.log"
nssm set $serviceName AppRotateFiles 1
nssm set $serviceName Description 'Service description'
nssm set $serviceName DisplayName 'Service Display Name'
nssm set $serviceName ObjectName LocalSystem
nssm set $serviceName Start SERVICE_AUTO_START
nssm set $serviceName Type SERVICE_WIN32_OWN_PROCESS

Zmień hasło

$SecurePassword = ConvertTo-SecureString "here_passoword" -AsPlainText -Force
$UserAccount = Get-LocalUser -Name "username"
$UserAccount | Set-LocalUser -Password $SecurePassword

Acl

Tutaj bardzo dobry art: https://blue42.net/windows/changing-ntfs-security-permissions-using-powershell/

Chown

Function Chown {
    Param ($_userName, $_path)

    $user = New-Object System.Security.Principal.NTAccount("$_userName")
    $acl = Get-Acl -Path $_path

    # Changing owner
    $acl.SetOwner($user)
    
    # Adding FullControl
    $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($user, "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
    $acl.AddAccessRule($rule)
    
    Set-Acl -Path $_path -AclObject $acl
}