WINDOWS: mudanças entre as edições
Ir para navegação
Ir para pesquisar
(27 revisões intermediárias pelo mesmo usuário não estão sendo mostradas) | |||
Linha 1: | Linha 1: | ||
=Network= | |||
*[[Windows Firewall|Windows Firewall]] | *[[Windows Firewall|Windows Firewall]] | ||
=PowerShell= | |||
==Users== | |||
*[[Get logged users|Get logged users]] | *[[Get logged users|Get logged users]] | ||
= | ==DNS== | ||
DUMP all RECORDS from all ZONES | |||
<syntaxhighlight lang=powershell> | |||
Remove-Item .\records.txt | |||
$DNSSERVER="192.168.83.1" | |||
$zones = (Get-DnsServerZone -ComputerName $DNSSERVER | Where-Object {$_.IsReverseLookupZone -like "False" } | Where-Object {$_.IsDsIntegrated -like "True" }).ZoneName | |||
foreach($zone in $zones) | |||
{ | |||
Get-DnsServerResourceRecord -ComputerName $DNSSERVER -ZoneName $zone | Out-File -Append -FilePath .\records.txt | |||
} | |||
</syntaxhighlight> | |||
Dump only records name | |||
<syntaxhighlight lang=powershell> | |||
Remove-Item .\records.txt | |||
$DNSSERVER="192.168.83.1" | |||
$zones = (Get-DnsServerZone -ComputerName $DNSSERVER | Where-Object {$_.IsReverseLookupZone -like "False" } | Where-Object {$_.IsDsIntegrated -like "True" }).ZoneName | |||
foreach($zone in $zones) | |||
{ | |||
$records = (Get-DnsServerResourceRecord -ComputerName $DNSSERVER -ZoneName $zone).Hostname | |||
foreach($record in $records) | |||
{ | |||
write-output "$record.$zone" | Out-File -Append -FilePath .\records.txt | |||
} | |||
} | |||
</syntaxhighlight> | |||
Create Conditional Forwards | |||
<syntaxhighlight lang=powershell> | |||
$lista = (Get-Location).path + "\lista.txt" | |||
$lista | |||
@" | |||
name.domain.com | |||
"@ > $lista | |||
$DNSSERVERS = "192.168.83.1","192.168.77.1" | |||
Foreach ($DNSSERVER in $DNSSERVERS) | |||
{ | |||
Foreach ($REGISTRO in [System.IO.File]::ReadLines($lista)) | |||
{ | |||
Add-DnsServerConditionalForwarderZone -ComputerName $DNSSERVER -Name $REGISTRO -MasterServers 172.16.10.5,172.16.10.6 -PassThru | |||
} | |||
} | |||
</syntaxhighlight> | |||
==Install WSL== | |||
Enable Linux Subsystem | |||
<syntaxhighlight lang=powershell> | |||
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux | |||
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform | |||
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart | |||
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart | |||
https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi | |||
wsl --set-default-version 2 | |||
</syntaxhighlight> | |||
Download Ubuntu WSL | |||
<syntaxhighlight lang=powershell> | |||
Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile Ubuntu.appx -UseBasicParsing | |||
# OR | |||
curl.exe -L -o ubuntu-1804.appx https://aka.ms/wsl-ubuntu-1804 | |||
</syntaxhighlight> | |||
Other tools | |||
<syntaxhighlight lang=powershell> | |||
#List | |||
wsl -l | |||
#Set version | |||
wsl --set-version <Distro> 2 | |||
#Set default version | |||
wsl --set-default-version 2 | |||
#List WSLs | |||
wsl --list --verbose | |||
wsl -l -v | |||
</syntaxhighlight> | |||
Ensure tha the service "Lxssmanager" is running. | |||
==[https://learn.microsoft.com/en-us/powershell/module/nettcpip/test-netconnection?view=windowsserver2025-ps NCAT like]== | |||
<syntaxhighlight lang=powershell> | |||
Test-NetConnection -ComputerName servername.domain -Port 3164 | |||
</syntaxhighlight> | |||
==RemoteExecution== | ==RemoteExecution== | ||
*[https://www.faqforge.com/windows/create-powershell-session-remote-computer/ Article] | *[https://www.faqforge.com/windows/create-powershell-session-remote-computer/ Article] | ||
Linha 34: | Linha 116: | ||
} | } | ||
</syntaxhighlight> | |||
==Get DELL Service TAG== | |||
<syntaxhighlight lang=powershell> | |||
Get-WmiObject win32_SystemEnclosure | select serialnumber | |||
</syntaxhighlight > | |||
==Uptime== | |||
<syntaxhighlight lang=powershell> | |||
Get-WmiObject Win32_OperatingSystem | Select-Object LastBootUpTime | |||
</syntaxhighlight> | |||
Prompt Method | |||
<pre> | |||
wmic path Win32_OperatingSystem get LastBootUpTime | |||
</pre> | |||
==Security== | |||
===Add member to LocalGroup=== | |||
<syntaxhighlight lang=powershell> | |||
Add-LocalGroupMember -group administrators -member domain_name\group_name | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=FailOverManager= | =FailOverManager= | ||
*[https://docs.vmware.com/en/VMware-vSphere/6.7/vsphere-esxi-vcenter-server-671-setup-mscs.pdf Setup for Failover Clustering and Microsoft Cluster Service] | *[https://docs.vmware.com/en/VMware-vSphere/6.7/vsphere-esxi-vcenter-server-671-setup-mscs.pdf VMWARE Setup for Failover Clustering and Microsoft Cluster Service] | ||
==Install== | ==Install== | ||
Listing windows features | Listing windows features | ||
Linha 50: | Linha 149: | ||
Install Windows Feature | Install Windows Feature | ||
<syntaxhighlight lang=powershell> | <syntaxhighlight lang=powershell> | ||
Install-WindowsFeature -name Failover-Clustering | |||
Install-WindowsFeature -name RSAT-Clustering | Install-WindowsFeature -name RSAT-Clustering | ||
</syntaxhighlight> | |||
Output | |||
<syntaxhighlight lang=powershell> | |||
PS C:\Windows\system32> Get-WindowsFeature Failover* | |||
Display Name Name Install State | |||
------------ ---- ------------- | |||
[X] Failover Clustering Failover-Clustering Installed | |||
PS C:\Windows\system32> Get-WindowsFeature RSAT-Cluster* | |||
Display Name Name Install State | |||
------------ ---- ------------- | |||
[X] Failover Clustering Tools RSAT-Clustering Installed | |||
[X] Failover Cluster Management Tools RSAT-Clustering-Mgmt Installed | |||
[X] Failover Cluster Module for Windows ... RSAT-Clustering-Powe... Installed | |||
[ ] Failover Cluster Automation Server RSAT-Clustering-Auto... Available | |||
[ ] Failover Cluster Command Interface RSAT-Clustering-CmdI... Available | |||
</syntaxhighlight> | |||
=ServiceFabric= | |||
*http://localhost:19080/Explorer | |||
Move App to other Node | |||
<syntaxhighlight lang=shell> | |||
Connect-ServiceFabricCluster | |||
Update-ServiceFabricService -ServiceName fabric:/Com.Company.App.Example/Com.Company.App.Example.Api -Stateless -InstanceCount 1 -PlacementConstraints "NodeType == TypeNameHere && NodeName==NodeNameHere" -Force | |||
Update-ServiceFabricService -ServiceName fabric:/Com.Company.App.Example/Com.Company.App.Example.Api -Stateful -PlacementConstraints "NodeType == TypeNameHere && NodeName==NodeNameHere" -Force | |||
</syntaxhighlight> | |||
=Storage= | |||
==Deduplication== | |||
===[https://docs.microsoft.com/en-us/powershell/module/deduplication/start-dedupjob?view=win10-ps Start-DedupJob]=== | |||
<syntaxhighlight lang=powershell> | |||
#Start a deduplication job | |||
Start-DedupJob -Volume "E:" -Type Optimization -Memory 60 -AsJob -Cores 6 -Full -Preempt | |||
#Recover space from insued deduplicated blocks | |||
Start-DedupJob -Volume "E:" -Memory 60 -Cores 6 -Type GarbageCollection -Preempt | |||
#Get dedup job status | |||
Get-DedupJob | |||
</syntaxhighlight> | |||
==NTFS== | |||
===Alternate Data Streams=== | |||
<pre> | |||
echo "This is a test" > test.txt | |||
echo "This is a secret" > test.txt:secretdata | |||
</pre> | |||
==[https://docs.microsoft.com/en-us/answers/questions/176301/resize-virtualdisk-says-34not-enough-available-cap.html Resize]== | |||
<syntaxhighlight lang=powershell> | |||
get-virtualDisk myDiskName | ft {$_.size/1GB} -hideTableHeader | |||
get-virtualDiskSupportedSize -storagePoolFriendlyName myPool | ft {$_.virtualDiskSizeMax/1GB} -hideTableHeader | |||
resize-virtualDisk -friendlyName myDiskName -size 10000gb | |||
get-storagePool myPool | optimize-storagePool | |||
restart-computer | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=LogRotate= | |||
*[https://www.itefix.net/logwot8 Logwot8 - Logrotate for Windows] | |||
*[https://github.com/logrotate/logrotate LogRotate source code] | |||
=Errors= | =Errors= | ||
Linha 71: | Linha 231: | ||
DISM.exe /online /enable-feature /all /featurename:NetFx4 | DISM.exe /online /enable-feature /all /featurename:NetFx4 | ||
</pre> | </pre> | ||
= | =Tools= | ||
==[[Dir Stat to CSV|Dir Stat to CSV]]== | |||
=Links= | |||
*[https://serviceshub.microsoft.com/ Service Hub] |
Edição atual tal como às 13h57min de 17 de dezembro de 2024
Network
PowerShell
Users
DNS
DUMP all RECORDS from all ZONES
Remove-Item .\records.txt
$DNSSERVER="192.168.83.1"
$zones = (Get-DnsServerZone -ComputerName $DNSSERVER | Where-Object {$_.IsReverseLookupZone -like "False" } | Where-Object {$_.IsDsIntegrated -like "True" }).ZoneName
foreach($zone in $zones)
{
Get-DnsServerResourceRecord -ComputerName $DNSSERVER -ZoneName $zone | Out-File -Append -FilePath .\records.txt
}
Dump only records name
Remove-Item .\records.txt
$DNSSERVER="192.168.83.1"
$zones = (Get-DnsServerZone -ComputerName $DNSSERVER | Where-Object {$_.IsReverseLookupZone -like "False" } | Where-Object {$_.IsDsIntegrated -like "True" }).ZoneName
foreach($zone in $zones)
{
$records = (Get-DnsServerResourceRecord -ComputerName $DNSSERVER -ZoneName $zone).Hostname
foreach($record in $records)
{
write-output "$record.$zone" | Out-File -Append -FilePath .\records.txt
}
}
Create Conditional Forwards
$lista = (Get-Location).path + "\lista.txt"
$lista
@"
name.domain.com
"@ > $lista
$DNSSERVERS = "192.168.83.1","192.168.77.1"
Foreach ($DNSSERVER in $DNSSERVERS)
{
Foreach ($REGISTRO in [System.IO.File]::ReadLines($lista))
{
Add-DnsServerConditionalForwarderZone -ComputerName $DNSSERVER -Name $REGISTRO -MasterServers 172.16.10.5,172.16.10.6 -PassThru
}
}
Install WSL
Enable Linux Subsystem
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
wsl --set-default-version 2
Download Ubuntu WSL
Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile Ubuntu.appx -UseBasicParsing
# OR
curl.exe -L -o ubuntu-1804.appx https://aka.ms/wsl-ubuntu-1804
Other tools
#List
wsl -l
#Set version
wsl --set-version <Distro> 2
#Set default version
wsl --set-default-version 2
#List WSLs
wsl --list --verbose
wsl -l -v
Ensure tha the service "Lxssmanager" is running.
NCAT like
Test-NetConnection -ComputerName servername.domain -Port 3164
RemoteExecution
Enable remote execution
Enable-PSRemoting -Force
Test connection
Test-WsMan localhost
Run remote command
$cred=Get-Credential
$sess = New-PSSession -Credential $cred -ComputerName localhost
Enter-PSSession $sess
#<remote command to execute>
Exit-PSSession
Remove-PSSession $sess
Remote execution from a server list
$cred=Get-Credential
foreach($line in [System.IO.File]::ReadLines("c:\list.txt"))
{
$line
$sess = New-PSSession -Credential $cred -ComputerName $line
Enter-PSSession $sess
c:\command_to_execute.exe
Exit-PSSession
Remove-PSSession $sess
}
Get DELL Service TAG
Get-WmiObject win32_SystemEnclosure | select serialnumber
Uptime
Get-WmiObject Win32_OperatingSystem | Select-Object LastBootUpTime
Prompt Method
wmic path Win32_OperatingSystem get LastBootUpTime
Security
Add member to LocalGroup
Add-LocalGroupMember -group administrators -member domain_name\group_name
FailOverManager
Install
Listing windows features
Get-WindowsFeature
Highlight Faiolver feature
Get-WindowsFeature Failover*
Get-WindowsFeature RSAT-Cluster*
Install Windows Feature
Install-WindowsFeature -name Failover-Clustering
Install-WindowsFeature -name RSAT-Clustering
Output
PS C:\Windows\system32> Get-WindowsFeature Failover*
Display Name Name Install State
------------ ---- -------------
[X] Failover Clustering Failover-Clustering Installed
PS C:\Windows\system32> Get-WindowsFeature RSAT-Cluster*
Display Name Name Install State
------------ ---- -------------
[X] Failover Clustering Tools RSAT-Clustering Installed
[X] Failover Cluster Management Tools RSAT-Clustering-Mgmt Installed
[X] Failover Cluster Module for Windows ... RSAT-Clustering-Powe... Installed
[ ] Failover Cluster Automation Server RSAT-Clustering-Auto... Available
[ ] Failover Cluster Command Interface RSAT-Clustering-CmdI... Available
ServiceFabric
Move App to other Node
Connect-ServiceFabricCluster
Update-ServiceFabricService -ServiceName fabric:/Com.Company.App.Example/Com.Company.App.Example.Api -Stateless -InstanceCount 1 -PlacementConstraints "NodeType == TypeNameHere && NodeName==NodeNameHere" -Force
Update-ServiceFabricService -ServiceName fabric:/Com.Company.App.Example/Com.Company.App.Example.Api -Stateful -PlacementConstraints "NodeType == TypeNameHere && NodeName==NodeNameHere" -Force
Storage
Deduplication
Start-DedupJob
#Start a deduplication job
Start-DedupJob -Volume "E:" -Type Optimization -Memory 60 -AsJob -Cores 6 -Full -Preempt
#Recover space from insued deduplicated blocks
Start-DedupJob -Volume "E:" -Memory 60 -Cores 6 -Type GarbageCollection -Preempt
#Get dedup job status
Get-DedupJob
NTFS
Alternate Data Streams
echo "This is a test" > test.txt echo "This is a secret" > test.txt:secretdata
Resize
get-virtualDisk myDiskName | ft {$_.size/1GB} -hideTableHeader
get-virtualDiskSupportedSize -storagePoolFriendlyName myPool | ft {$_.virtualDiskSizeMax/1GB} -hideTableHeader
resize-virtualDisk -friendlyName myDiskName -size 10000gb
get-storagePool myPool | optimize-storagePool
restart-computer
LogRotate
Errors
0xc0000135
Message
--------------------------- ServerManager.exe - Application Error --------------------------- The application was unable to start correctly (0xc0000135). Click OK to close the application. --------------------------- OK ---------------------------
Solution
DISM.exe /online /enable-feature /all /featurename:NetFx3 or DISM.exe /online /enable-feature /all /featurename:NetFx4