• Home
  • PS
  • C#
  • Perl
  • MSSQL
  • MariaDB
  • Linux
  • Docker
  • MacOS
  • PG
  • Exchange Server
  • Windows
  • Other

Test-RebootRequired

Details
Written by: po3dno
Category: Power Shell
Created: 01 February 2023
Hits: 429

Read more …

PowerShell equivalents for Repadmin commands

Details
Written by: po3dno
Category: Power Shell
Created: 10 November 2022
Hits: 517
Get replication partner status
repadmin /showrepl Get-ADReplicationPartnerMetadata
Get Inbound replication queue details
repadmin /queue Get-ADReplicationQueueOperation
Replicate specific AD objects between domain controllers
repadmin /replsingleobj Sync-ADObject
Get replication metadata of an AD object
repadmin /showobjmeta Get-ADReplicationAttributeMetadata
Shows highest committed USN
repadmin /showutdvec Get-ADReplicationUpToDatenessVectorTable
Displays ISTG details
repadmin /istg * Get-ADReplicationSite –filter * | Select InterSiteTopologyGenerator
List all the subnets in the forest
dsquery subnet Get-ADReplicationSubnet
List the AD sites in the domain
dsquery site Get-ADReplicationSite

 

Get-ADReplicationPartnerMetadata -Target $env:computername |Select Server,@{n="Partner";e={(Resolve-DnsName $_.PartnerAddress).NameHost}},LastReplicationAttempt,LastReplicationResult, LastReplicationSuccess

 

Рекурсивный merge AVHDX

Details
Written by: po3dno
Category: Power Shell
Created: 19 October 2021
Hits: 974

$vhd = Get-ChildItem -Filter base* | Get-VHD 

$curdisk = "e:\export\virtual hard disks\base-w2019en.vhdx"; 
function Get-ParentAVHDX {
  param ($p); 
  $pp = $vhd | ?{$_.parentpath -eq $p}; 
  if ($pp) {
    Get-ParentAVHDX($pp.path); 
    write-host $pp.path $pp.parentpath; 
    Merge-VHD -Path $pp.Path -DestinationPath $pp.ParentPath -Verbose -WhatIf
  }
} 
Get-ParentAVHDX($curdisk)

secedit

Details
Written by: po3dno
Category: Power Shell
Created: 05 October 2021
Hits: 971
$account = "accountName"
$userRight = "SeServiceLogonRight*"

$code = (Start-Process secedit -ArgumentList "/export /areas USER_RIGHTS /cfg c:\policies.inf" -Wait -PassThru).ExitCode
if ($code -eq 0)
    {
        Write-Output "security template exported successfully exit code $code"
    }
else
    {
        Write-Output "security template export failed exit code $code"
    }

$sid = ((Get-LocalUser $account).SID).Value

$policy = Get-Content C:\policies.inf
$newpol = @()
foreach ($line in $policy)
    {
        if ($line -like $userRight)
            {
                $line = $line + ",*$sid"
            }

        $newpol += $line
    }

$newpol | Out-File C:\policies.inf -Force

$code = (Start-Process secedit -ArgumentList "/configure /db secedit.sdb /cfg C:\policies.inf /areas USER_RIGHTS /log C:\policies.log" -Wait -PassThru).ExitCode
if ($code -eq 0)
    {
        Write-Output "exit code $code"
    }
else
    {
        Write-Output "exit code $code"
    }

Remove-Item -Path c:\policies.inf -Force

iso uefi

Details
Written by: po3dno
Category: Power Shell
Created: 05 July 2021
Hits: 1093

Mount-WindowsImage -Path .\iso -ImagePath 'C:\VMs\w2012r2_en\Virtual Hard Disks\w2012r2_en.vhdx' -Index 1

New-WindowsImage -CapturePath .\iso -Name "Windows 2012R2 2111" -ImagePath C:\winpe_x64\install.wim -Description "Windows 2012R2 2111" -Verify

Dismount-WindowsImage -Path .\iso\ -Discard

unpack iso

replace install.wim

.\oscdimg.exe -m -o -u2 -udfver102 -bootdata:2#p0,e,bC:\winpe_x64\ISO\boot\etfsboot.com#pEF,e,bC:\winpe_x64\ISO\efi\microsoft\boot\efisys.bin c:\winpe_x64\ISO D:\VM\ISO\SW_DVD9_Windows_Svr_Std_and_DataCtr_2012_R2_64Bit_Russian_-4_MLF_X19-82917_2111.iso

  1. Reset WSUS Authorization and get new WSUS SID
  2. Convert AD BASE64 SID to SDDL format and back.
  3. Disable NLA
  4. How to clean out golden tickets after a succesful attack on your active directory

Page 2 of 11

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

Login Form

  • Forgot your password?
  • Forgot your username?

Statistics

  • Users 2
  • Articles 164
  • Articles View Hits 149004