Quickly Find Your local IP Address
Detailed IP Address
Flush Your DNS Resolver Cache
Renew IP Address
Release IP Address
Flush Your DNS Resolver Cache
Updates a host A/AAAA record within your active directory integrated DNS
Displays the contents of the DNS Resolver Cache
Resetting Network Adapter (Winsock Reset)
Get mac addresses
Send packets to that address
ping.exe -t google.com | ForEach {"{0} - {1} " -f (Get-Date), $_} >> C:\temp\pinggoogle.txt
Send packets to that address and returns the hostname
Send packets to that hostname and returns the IPv4 address
Send packets to that hostname and returns the IPv6 address
Traces the route it takes for a packet to reach a destination
Trace route and provide network latency and packet loss for each router and link in the path. Combines the functionality of PING and TRACERT.
Checks availabe hosts on the network
shutdown /s /t 0 - immediate shutdown
shutdown /r /t 0 - immediate restart
shutdown /r /o - restarts the computer into advanced options
Shutdown Shortcuts
CHKDSK is a Windows utility that can check the integrity of your hard disk and can fix various file system errors.
/f - fix errors /r - relocate bad sectors /v - displays the path of every file
Scan System Files for Problems
w32tm /stripchart /computer:localhost /dataonly /samples:3
Determine if there are any corruptions inside the local image. However, the option won't perform any repairs.
Alternatively, you can run DISM with the ScanHealth option to perform a more advanced scan to check if the Windows 10 image has any problems
Fix Windows Update errors - RestoreHealth option, which will run an advanced scan and repair any problems automatically.
Fix image issues using a DVD/USB with Windows 10
Connect to Telnet Servers
Permanently Delete and Overwrite a Directory cipher /w:C:\Users\svetlozar\Desktop\testDel
Removes directory even if it is not empty
List Network Connections and Ports
Rsetrieve the mac addressses for a remote computer
Find the IP Address Associated With a Domain
Displays the current domain and user name
Displays the computer's hostname
Shows users on the computer (Network places wizard)
Creates user Svet and sets the password to 1234
Adds user to group
taskkill /IM outlook.exe
net localgroup administrators AzureAD\SvetLyo /add
Sets the password for Svet to never expire
net user Svet 1234 /ADD && net localgroup Administrators Svet /add && WMIC USERACCOUNT WHERE Name='Svet' SET PasswordExpires=FALSE
wmic diskdrive get Name, Manufacturer, Model, InterfaceType, MediaType, SerialNumber.
Find the Windows version
Device manager
Task manager
Force Update Group Policy
Display or change the association between a file extension and a fileType assoc .doc=word
Lists all installed device drivers and their properties driverquery -v Optain more information
List system configuration
Generate System Performance Report
Control power settings, configure Hibernate/Standby modes.
Turns on hibernation
Turns off hibernation
Lists all available PC power saving states
Generates power consumption report
TaskList displays all running applications and services with their Process ID
Shows services related to each task use
Detailed task list
Locates .dll files
Kills the task with process ID of 0000
Microsoft Windows Malicious Software Removal Tool
mrt /? - help
mrt /f - force full scan
wmic diskdrive list brief
wmic path softwarelicensingservice get OA3xOriginalProductKey
troubleshoot TCP/IP connectivity issues Download PortQryV2.exe, a command-line utility that you can use to help troubleshoot TCP/IP connectivity issues. Portqry.exe runs on Windows 2000-based computers
Check for the Trusted Platform Module
Opens Control Panel
Computer Management
Task manager
Create/connect to a (VPN) network
Run Windows Memory Diagnostic Tool
verifier.exe /standard /all
reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\taskmgr.exe" /v Debugger
Windows logo key + R,type shell:startup
, then select OK. This opens the Startup folder. Copy and paste the shortcut to the app from the file location to the Startup folder.
rem reg add "HKLM\Software\Policies\Microsoft\Windows" /v PreventIndexingOutlook /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Office\16.0\Common\ExperimentsEcs\Overrides" /v Microsoft.Office.Outlook.Hub.HubBar /t REG_SZ /d False /f
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\utilman.exe" /v Debugger /t REG_SZ /d cmd.exe /f
#Get-ChildItem "." -Filter *.eml -Recurse | Select-String "undeliverable"| Select Filename, LineNumber, Line, Path | Format-Table > filename.txt
Get-ChildItem "." -Filter *.eml -Recurse | Select-String "undeliverable"| Select Filename | Format-Table > filename.txt
Get-Content .\filename.txt
#Manually remove obsolete lines
Get-Content .\filename.txt | Remove-Item -Verbose
@echo off cmd /k reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\full" /v version
(put the .bat file in the same location as .rdp file)
@echo off
:: Connecting to VPN...
rasphone.exe -d "ChangeMeVPN-NAME"
echo Running RDP...
"ChangeMeRDP-NAME.rdp"
echo Finished - disconnecting from VPN...
rasphone.exe -h "ChangeMeVPN-NAME"
At the end, navigate to C:\Users$env:UserName\AppData\Roaming\Microsoft\Network\Connections\Pbk and edit the rasphone.pbk file by changing PreviewUserPw=0 from 1 to 0
reg add "HKLM\SOFTWARE\Microsoft\PolicyManager\default\Settings\AllowSignInOptions" /v value /t REG_DWORD /d 0 /f
rem Windows Telemetry must not be configured to Full
reg add "HKLM\Software\Policies\Microsoft\WindowsDataCollection\" /v AllowTelemetry /t REG_DWORD /d 0 /f
rem If Enhanced diagnostic data is enabled it must be limited to the minimum required to support Windows Analytics
reg add "HKLM\Software\Policies\Microsoft\WindowsDataCollection\" /v LimitEnhancedDiagnosticDataWindowsAnalytics /t REG_DWORD /d 1 /f
reg query "HKLM\Software\Microsoft\Windows Defender\Exclusions\Extensions"
reg query "HKLM\Software\Microsoft\Windows Defender\Exclusions\IpAddresses"
reg query "HKLM\Software\Microsoft\Windows Defender\Exclusions\Paths"
reg query "HKLM\Software\Microsoft\Windows Defender\Exclusions\Processes"
reg query "HKLM\Software\Microsoft\Windows Defender\Exclusions\TemporaryPaths"
robocopy "A:\source\" "B:\destination\" /E /ZB /COPYALL /R:2 /W:2 /MT:6 /LOG+:c:\robocopy.log /tee
robocopy "A:\source\" "B:\destination" /E /ZB /COPYALL *.png *.jpg *.jpeg /R:2 /W:2 /MT:5 /LOG+:c:\robocopy.log /tee
add wireshark to your path environment C:\Program Files\Wireshark
"C:\Program Files\Wireshark\Wireshark.exe"
"C:\Program Files\Wireshark\Wireshark.exe" -D - interfaces
"C:\Program Files\Wireshark\tshark.exe" -i 6 -w "D:\wirtest.pcapng"
"C:\Program Files\Wireshark\tshark.exe" -w "D:\wirtest.pcapng"
tshark.exe -i 6 -b duration:1800 -w "D:\wirtest.pcapng"
dumpcap.exe -i 6 -w "D:\wirtest.pcapng" -b filesize:500000 -b files:1000
https://www.microsoft.com/en-us/download/4865
nmcap /usage
nmcap /displaynetworks
nmcap /network 2 /capture /captureProcesses /StopWhen /TimeAfter 1440 min /file "D:\db.cap":102400M
nmcap /network * /capture /captureProcesses /StopWhen /TimeAfter 1440 min /file "D:\db.cap"
nmcap /network * /capture /captureProcesses /StopWhen /TimeAfter 1440 min /file "M:\db.cap"
nmcap /network * /capture /captureProcesses /StopWhen /TimeAfter 1440 min /file "M:M:\wireshark1\netmon\wh1.cap"
nmcap /network * /capture /captureProcesses /StopWhen /TimeAfter 1440 min /file "M:\wh2.cap"
nmcap /network * /capture /captureProcesses /StopWhen /TimeAfter 1440 min /file "M:\db.cap"
"C:\Program Files\Microsoft Network Monitor 3\nmcap.exe" /usage
"C:\Program Files\Microsoft Network Monitor 3\nmcap.exe" /network * /capture /captureProcesses /StopWhen /TimeAfter 1440 min /file "M:\wireshark1\netmon\wh1.cap"
"C:\Program Files\Microsoft Network Monitor 3\nmcap.exe" /network * /capture /captureProcesses /StopWhen /TimeAfter 1440 min /file "M:\wireshark1\netmon\wh1.cap"
"C:\Program Files\Microsoft Network Monitor 3\nmcap.exe" /network * /capture /captureProcesses /StopWhen /TimeAfter 1440 min /file "M:\wireshark2\netmon\wh2.cap"
"C:\Program Files\Microsoft Network Monitor 3\nmcap.exe" /network * /capture /captureProcesses /StopWhen /TimeAfter 1440 min /file "M:\netmon\db.cap"
msdt.exe -id MaintenanceDiagnostic
msdt.exe /id WindowsUpdateDiagnostic
manage-bde -status c:
Unblocks blocked file in the current directory and it's childrens
Software Licensing Management Tool slmgr /dli - checks part of the product key
powershell “(Get-WmiObject -query ‘select * from SoftwareLicensingService’).OA3xOriginalProductKey”
Get-service -displayname veeam* | stop-service Get-service -displayname veeam* | start-service
Displays the computer's hostname
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber"
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber" -Value 3423 New-NetFirewallRule -DisplayName 'RDPPORTLatest' -Profile 'Public' -Direction Inbound -Action Allow -Protocol TCP -LocalPort 3423
Test-NetConnection -ComputerName **HOSTNAME** -Port **PORTNUMBER**
$Ports = @(25, 143, 465, 587, 993, 2525)
foreach ($Port in $Ports) {
Test-NetConnection -ComputerName 10.0.0.59 -Port $Port
}
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize
Get-WmiObject win32_product
Get-CimInstance win32_product
Compress-Archive -LiteralPath ".\outlook.pst" -DestinationPath ".\outlook.zip" -CompressionLevel Optimal -Force -Verbose
or
$source = '.'
$destination = "C:\Users\$env:UserName\Desktop"
$subfolders = Get-ChildItem $source -Directory -Recurse
Compress-Archive -Path $source -DestinationPath "$destination\archive.zip" -CompressionLevel Fastest -Force -Verbose
You can also add the date and time
$d = Get-Date -Format "dddd-MM-dd-yyyy"
Compress-Archive -LiteralPath ".\0\" -DestinationPath ".\$d.zip" -CompressionLevel Optimal -Force -Verbose
"C:\Program Files\7-Zip\7z" a -tzip "C:\archive_%date%_.zip" "M:\Ethical Hacking\tools\*.*" -r -mm=LZMA -mmt=on -mx9 -md=256m -mfb=256 -sccUTF-8 "-p0" -mem=AES256
"C:\Program Files\7-Zip\7z" u "C:\tmp\archive.zip" "M:\Ethical Hacking\3 SCANNING & ENUMERATION\*.*"
"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqldump.exe" -u USER -pPASSWORD -h SERVERNAME DATABASENAME > "WEBSITELOCATION\DATABASE.sql"
"C:\Program Files\7-Zip\7z" a -tzip "BACKUPLOCATION\%date%_.zip" WEBSITELOCATION\*.*" -r -mm=LZMA -mmt=on -mx9 -md=256m -mfb=256 -sccUTF-8 "-pPUTAPASSWORDHERE" -mem=AES256
del "WEBSITELOCATION\DATABASE.sql"
Push-Location "C:\Program Files\MySQL\MySQL Server 5.7\bin\"
.\mysqldump.exe -u USER -pPASSWORD -h SERVERNAME DATABASENAME > "WEBSITELOCATION\DATABASE.sql"
$d = Get-Date -Format "dd-MM-yyyy-dddd"
Compress-Archive -LiteralPath "WEBSITELOCATION\" -DestinationPath "BACKUPLOCATION\$d.zip" -CompressionLevel Optimal -Force
Push-Location "WEBSITELOCATION"
Remove-Item DATABASE.sql
## 1
Get-ChildItem -Path "C:\archive" -File -Recurse | Remove-Item -Verbose
## 2
$folderPath = "C:\archive\"
$user = "$env:USERNAME"
$accesstype = "FullControl"
$argList = $user, $accesstype, $allowOrDeny
$allowOrDeny = "Allow"
$acl = Get-Acl $folderPath
$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule -ArgumentList $argList
$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule ($user, $accesstype, $allowOrDeny)
$acl.SetAccessRule($AccessRule)
$acl | Set-Acl $folderPath
## 3
$folderPath = "C:\archive\"
$user = "$env:USERNAME"
$grant = "/grant:r"
$permission = ":(OI)(CI)(F)"
$inhertance = "/inheritance:e"
Invoke-Expression -Command ('icacls $folderPath $inhertance $grant "${user}${permission}"')
$limit = (Get-Date).AddDays(-14)
Get-ChildItem -Path . -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit }
$limit = (Get-Date).AddDays(-7)
Get-ChildItem -Path . -Filter *.dmp -Recurse -ErrorAction SilentlyContinue -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -gt $limit }
and export the results
| ConvertTo-Csv | Out-File "C:\logs7.csv"
Get-ChildItem . -Recurse | Remove-Item -Recurse -Force -Verbose
Get-ChildItem @(
"C:\Windows\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientTools-Package*.mum",
"C:\Windows\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientExtensions-Package*.mum"
) | ForEach-Object { dism.exe /online /norestart /add-package:"$_" }
Needs CMD as Administrator on Both Machines. On the DC type:
djoin.exe /provision /domain "EXAMPLE.LOCAL" /machine "CLIENTPCNAME" /savefile C:\join.txt
Copy Over the File to the Client's Machine. In CMD type:
djoin.exe /requestodj /loadfile C:\join.txt /windowspath %systemroot% /localos
Get-EventLog -LogName System -After ((get-date).AddDays(-30)) -EntryType Error, Warning | ConvertTo-Csv | Out-File -FilePath C:\Users\$env:UserName\Desktop\EVENTLOGS\SYSTEMlast30days.csv -Force
Get-EventLog -LogName Security -After ((get-date).AddDays(-30)) -EntryType Error,FailureAudit,SuccessAudit,Warning | ConvertTo-Csv | Out-File -FilePath C:\Users\$env:UserName\Desktop\EVENTLOGS\SECURITYlast30days.csv -Force
Get-EventLog -LogName Application -After ((get-date).AddDays(-30)) -EntryType Error, Warning | ConvertTo-Csv | Out-File -FilePath C:\Users\$env:UserName\Desktop\EVENTLOGS\APPLICATIONlast30days.csv -Force
Get-EventLog -LogName Security -After ((get-date).AddDays(-1)) | where {$_.EventID -eq 4771} | ConvertTo-Csv | Out-File -FilePath .\Secyritylast1dayID4771.csv -Force
WEVTUtil query-events "Microsoft-Windows-Sysmon/Operational" /format:xml /e:sysmonview > c:/sysmon/sysmoneventlog.xml
Search-ADAccount –AccountDisabled –UsersOnly –ResultPageSize 2000 –ResultSetSize $null | Select-Object SamAccountName, DistinguishedName
Get-ADUser -Filter 'enabled -eq $true' | Select-Object GivenName, Name, SamAccountName, UserPrincipalName | ConvertTo-Html | Out-File .\enabled.html
Get-WindowsFeature | Where-Object {$_. installstate -eq "installed"} | Format-List Name,Installstate
Get-MailboxStatistics "EmailAddress" | Select-Object -Property DisplayName,TotalitemSize
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | Select-Object DisplayName,TotalItemSize
Get-MessageTrackingLog -ResultSize Unlimited -Sender EmailAddress -Recipients EmailAddress | out-gridview
Get-MobileDeviceStatistics -Mailbox svet@example.com | Select -Property LastSuccessSync, LastSyncAttemptTime, DeviceUserAgent, DeviceModel, DeviceFriendlyName, DeviceOS ,Guid | Convertto-Csv | Out-File svet-devices.csv
Get-ADPrincipalGroupMembership Svet | Select Name
Get-ADUser Svet -Properties Memberof | Select -ExpandProperty memberOf
Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize:Unlimited | Select-Object Identity,Alias,DisplayName | Sort DisplayName
Get-Mailbox | Get-MailboxPermission -User Svet
Get-Mailbox -RecipientTypeDetails UserMailbox,SharedMailbox -ResultSize Unlimited | Get-MailboxPermission -User Svet
Get-Mailbox | Get-MailboxPermission -User Svet
Get-Mailbox | Get-RecipientPermission -Trustee Svet
(If you see the error <<The term 'Get-MailboxPermission' is not recognized as the name of a cmdlet>> please add the snapin):
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn;
Get-Mailbox -RecipientTypeDetails UserMailbox -ResultSize Unlimited | Get-RecipientPermission -Trustee Svet
Get-Mailbox | ? {$_.GrantSendOnBehalfTo -match "Svet"}
Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize Unlimited | ? { (Get-MailboxPermission $_.UserPrincipalName | ? {$_.User -ne "NT AUTHORITY\SELF"}).Count -eq 0 }
Get-Mailbox -ResultSize Unlimited -Filter {GrantSendOnBehalfTo -eq $null}
cd "C:\Program Files\Microsoft\Exchange Server\V15\Scripts"
.\Disable-AntimalwareScanning.ps1
Restart-Service MSExchangeTransport -Verbose
Get-Service *exchange* | Where-Object {$_.Status -eq "Running"}
Get-Mailbox -Identity ChikiRikiMailbox
Set-Mailbox ChikiRikiMailbox -MessageCopyForSentAsEnabled $True
set-mailbox -Identity ChikiRikiMailbox -MessageCopyForSentAsEnabled $False
Create an outbound rule
RESPONSE_Server
#Restart a Web App Pool and IIS a Wesbsite
#CopyLeft SVET :)
$wap = Read-Host -Prompt 'Input the Web App Pool Name'
Write-Host "`n$line"
Write-Host "Next actions will be performed on App Pools and IIS websites that contain $wap in their name !!!" -ForegroundColor Yellow
Write-Host "`n$line"
Get-Website -Name *$wap*
Get-WebAppPoolState -Name *$wap*
$yesno = Read-Host -Prompt 'Do you wish to proceed with stopping the website? y/n:'
if ($yesno -like 'y'){
Restart-WebAppPool -Name *$wap* -verbose
#Stop-WebAppPool -Name *$wap* -verbose
#Start-WebAppPool -Name *$wap* -verbose
Write-Host "`n$line"
Write-Host "App Pools that contain $wap were sucessfully restarted!" -ForegroundColor Green
Write-Host "`n$line"
Stop-Website *$wap* -Verbose
Write-Host "`n$line"
Write-Host "IIS Websites that contain $wap in their name were STOPPED !!!" -ForegroundColor RED
Write-Host "`n$line"
Start-Website *$wap* -Verbose
Write-Host "`n$line"
Write-Host "IIS Websites that contain $wap in their name were sucessfully started!" -ForegroundColor Green
Write-Host "`n$line"
Write-Host "The Window will close in 5 seconds"
Start-Sleep -Seconds 5
}
else {
Write-Host Negative User Choise
}
& $env:windir\system32\inetsrv\appcmd list apppools /state:Started /xml | & $env:windir\system32\inetsrv\appcmd recycle apppools /in
iisreset /start
#Stop a Web App Pool and IIS a Wesbsite
#CopyLeft SVET :)
$wap = Read-Host -Prompt 'Input the Web App Pool Name'
Write-Host "`n$line"
Write-Host "Next actions will be performed on App Pools and IIS websites that contain $wap in their name !!!" -ForegroundColor Yellow
Write-Host "`n$line"
Get-Website -Name *$wap*
Get-WebAppPoolState -Name *$wap*
$yesno = Read-Host -Prompt 'Do you wish to proceed with stopping the website? y/n:'
if ($yesno -like 'y'){
Stop-WebAppPool -Name *$wap* -verbose
#Start-WebAppPool -Name *$wap* -verbose
Write-Host "`n$line"
Write-Host "App Pools that contain $wap were sucessfully stopped!" -ForegroundColor Green
Write-Host "`n$line"
Stop-Website *$wap* -Verbose
Write-Host "`n$line"
Write-Host "IIS Websites that contain $wap in their name were STOPPED !!!" -ForegroundColor RED
Write-Host "`n$line"
Write-Host "The Window will close in 5 seconds"
Start-Sleep -Seconds 5
}
else
{
Write-Host Negative User Input!
}
#Stop a Web App Pool and IIS a Wesbsite
#CopyLeft SVET :)
$wap = Read-Host -Prompt 'Input the Web App Pool Name'
Write-Host "`n$line"
Write-Host "Next actions will be performed on App Pools and IIS websites that contain $wap in their name !!!" -ForegroundColor Yellow
Write-Host "`n$line"
Get-Website -Name $wap
Get-WebAppPoolState -Name $wap
$yesno = Read-Host -Prompt 'Do you wish to proceed with stopping the website? y/n:'
if ($yesno -like 'y'){
Remove-WebAppPool -Name $wap -verbose
#Start-WebAppPool -Name *$wap* -verbose
Write-Host "`n$line"
Write-Host "App Pool was sucessfully removed!" -ForegroundColor Green
Write-Host "`n$line"
Get-Website -Name $wap
Remove-Website $wap -Verbose
Write-Host "`n$line"
Write-Host "IIS Website was sucessfully removed !!!" -ForegroundColor RED
Write-Host "`n$line"
Write-Host "The Window will close in 5 seconds"
Start-Sleep -Seconds 5
}
else {
Write-Host Negative User Choise
}
$site = Read-Host -Prompt 'Input the website Name'
Write-Host "`n$line"
Write-Host "Next actions will be performed on IIS websites that contain $site in their name !!!" -ForegroundColor Yellow
Write-Host "`n$line"
Wrrite-Host "Total bindings are "
Get-WebBinding -Name $site | measure
Get-WebBinding -Name $site
Write-Host "SSL Bindings are"
Get-WebBinding -name $site | Where-Object -Property sslFlags -eq 1
Get-WebBinding -name $site | Where-Object -Property sslFlags -eq 1 | measure
Write-host "NO SSL bindings are"
Get-WebBinding -name $site | Where-Object -Property sslFlags -eq 0
Get-WebBinding -name $site | Where-Object -Property sslFlags -eq 0 | measure
Start-Sleep -Seconds 5
%windir%\system32\inetsrv\appcmd list site > c:\sites.xls
Get-WebBinding | ConvertTo-Csv | Out-File "C:\bindings.csv" -Force -Verbose
Get-Website | ConvertTo-Csv | Out-File "C:\sites.csv" -Force -Verbose
Get-Website | Select-Object -ExpandProperty Bindings | ft
# Get-Website | Select-Object -ExpandProperty Bindings | Select-Object Collection
#BEGIN - manual
#
Get-Website | Select-Object -Property Name | Out-File test444.log
Write-Host -Separator `n
Write-Host -Separator `n
Get-Website | Select-Object -ExpandProperty physicalPath | Add-Content test444.log
Write-Host -Separator `n
Write-Host -Separator `n
Get-Website | Select-Object -ExpandProperty Bindings | Select-Object Collection | clip
#Paste the clipboard in the .log file
#END - manual
$ws = Get-Website
$ws.PhysicalPath
$ws.PhysicalPath | ConvertTo-Html | Out-File C:\Users\$env:UserName\Desktop\path.html
$ws.Bindings.Collection
$ws.Bindings.Collection | ConvertTo-Html | Out-File C:\Users\$env:UserName\Desktop\bindings.html
- Import the JSON file to a variable
$import = Get-Content .\json.json
$import
- Convert from JSON to PowerShell object
$import = Get-Content .\json.json | ConvertFrom-Json
$import
- Get object Members, Properties and Methods
$import | Get-Member
- Get actual information
$import.members
$import.members.age
- Upload the phpinfo.php file in the website root dir
- In a text file add all website URL to be scanned
- Use Linux
bash wget -i sites.txt
to get all the data - Find in files the php version using Notepad++
- Open all results as tabs in Notepadd++
- Find in files $_SERVER['SERVER_NAME'] to list the websites using the php version from point 4
grep -v "200" wh2u_ex220910_x.log > wh2no200.log
New-SelfSignedCertificate -CertStoreLocation Cert:\CurrentUser\My -Type CodeSigningCert -Subject "CN=Svet Kosev" -FriendlyName "Svet Kosev PowerShell" -NotAfter 12-07-2023
$cert = New-SelfSignedCertificate -CertStoreLocation Cert:\CurrentUser\My -Type CodeSigningCert -Subject "CN=Svet Kosev" -FriendlyName "Svet Kosev PowerShell" -NotAfter 12-07-2023
Move-Item -Path $cert.PSPath -Destination "Cert:\CurrentUser\Root"
$CodeCert = Get-ChildItem -Path "Cert:\CurrentUser\Root" -CodeSigningCert
Set-AuthenticodeSignature -FilePath ..\exportLog.ps1 -Certificate $CodeCert
pushd "%~dp0"
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt
for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
del hyper-v.txt
Dism /online /enable-feature /featurename:Microsoft-Hyper-V -All /LimitAccess /ALL
pause
Get-VM
$vmname = Read-Host -Prompt "Choose a VM for Failover"
$status = Get-VM -ComputerName Server2012 -Name $vmname | Select -ExpandProperty Status
$state = Get-VM -ComputerName Server2012 -Name $vmname | Select -ExpandProperty State
Write-Host Status is $status and State is $state
if ( $status -like "Operating Normally" -and $status -like "Running")
{
Write-Host Stopping $vmname now... -ForegroundColor Yellow
Stop-VM -ComputerName Server2012 -Name $vmname
Write-Host $vmname has been shutted down -ForegroundColor Green
Start-Sleep -Seconds 5
}
else
{
Write-Host Please turn it off manually!!!
Start-Sleep -Seconds 5
}
#Fail Over Steps
Get-VMReplication
Write-Host Preparing planned failover of the primary VM -ForegroundColor Yellow
Start-VMFailover -Prepare -VMName $vmname -ComputerName Server2012
Write-Host Preparing Completed -ForegroundColor Green
Write-Host Failing over the Replica virtual machine -ForegroundColor Yellow
Start-VMFailover -VMName $vmname -ComputerName DC
Write-Host Failing over Completed -ForegroundColor Green
Get-VMReplication
Write-Host Switching the Replica virtual machine to a primary virtual machine -ForegroundColor Yellow
Set-VMReplication -Reverse -VMName $vmname -ComputerName DC
Write-Host Switching Completed -ForegroundColor Green
Write-Host Starting the virtual machine -ForegroundColor Yellow
Start-VM -VMName $vmname -ComputerName DC
Write-Host $vmname is up and running -ForegroundColor Green
Get-VMReplication
Start-Sleep -Seconds 5
#Fail Back Steps
Get-VMReplication
Write-Host Preparing planned failover of the replica VM -ForegroundColor Yellow
Start-VMFailover -Prepare -VMName $vmname -ComputerName DC
Write-Host Preparing Completed -ForegroundColor Green
Write-Host Failing over the Primary virtual machine -ForegroundColor Yellow
Start-VMFailover -VMName $vmname -ComputerName Server2012
Write-Host Failing over Completed -ForegroundColor Green
Get-VMReplication
Write-Host Switching the primary virtual machine to a replica virtual machine -ForegroundColor Yellow
Set-VMReplication -Reverse -VMName $vmname -ComputerName Server2012
Write-Host Switching Completed -ForegroundColor Green
Write-Host Starting the virtual machine -ForegroundColor Yellow
Start-VM -VMName $vmname -ComputerName Server2012
Write-Host $vmname is up and running -ForegroundColor Green
Get-VMReplication
Start-Sleep -Seconds 5
cd C:\Program Files\Oracle\VirtualBox
.\VBoxManage.exe clonemedium --format vhd "F:\VMs\wazuh-4.3.5-disk-1.vmdk" "F:\VMs\wazuh-4.3.5-disk-1.vhd"
Open PowerShell with elevated privileges.
Install-Module AzureAD
Install-Module MSOnline
$credential = Get-Credential
Connect-MsolService -Credential $credential
Set-MsolUser -UserPrincipalName <name of the account> -PasswordNeverExpires $true
Set-MsolUser -UserPrincipalName user@example.com -PasswordNeverExpires $true
Get-ChildItem .\ -recurse | Sort-Object length -descending | select-object -first 32 | ft name,length -wrap –auto
D:\DFSRStaging\{{FOLDERNAME}}\Staging
(Get-ChildItem -Recurse | Sort-Object -Descending -Property Length | Select-Object -First 32 Name, Length | Measure-Object -Property Length -Sum).SUM /1MB
(Get-ChildItem -Recurse | Sort-Object -Descending -Property Length | Select-Object -First 32 Name, Length | Measure-Object -Property Length -Sum).SUM /1GB
net localgroup administrators AzureAD\SvetLyo /add
Delete obsolete text between brakets - 74.34 KB (76,120 bytes) to 74.34 KB
\s\((.*)\)
C:$Recycle.Bin
run this in cmd.exe as an admin:
pushd "%~dp0"
dir /b %SystemRoot%\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientExtensions-Package~3*.mum >List.txt
dir /b %SystemRoot%\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientTools-Package~3*.mum >>List.txt
for /f %%i in ('findstr /i . List.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages%%i"
pause
get-netfirewallrule | select-object name, group, action, enabled, profile | export-csv C:\firewallrulesexported.csv
Turning off
shutdown /s /m \RemoteComputerName
Rebooting
shutdown /r /m \RemoteComputerName
Restart a remote computer with a custom message:
Shutdown /m \pc2 /c "The IT department has initiated a remote restart on your computer"
Enter-PSSession -ComputerName <<PCNAME>> -Credential <<DOMAIN\USERNAME>>
Check the user/session ID
quser
Terminate the connection
logoff User_Session_ID