lunes, 17 de enero de 2022

WINDOWS. PS. History Command

 Purpose

Chek the last commands introduces at the PS console.

Dificulty: Low


Steps
 
Command: Get-History
 

For clear this list:

Command: Clear-History
 
Other options:
 
Command: Get-History | Select ID,Commandline

 
 
Command: Invoke-History 3


Command: Get-History | Format-List -Property *
 
 
Command: Get-History |  Select-String -Pattern "list"
 

 
 
 

by GoN | Published: Jan 17, 2022 | Last Updated:

lunes, 1 de noviembre de 2021

WINDOWS. Restore Point

Purpose

Create a restore point in my Windows computers

Steps

# Este comando habilita la protección del sistema en la unidad C:\
# This command enables system protection on drive C: \

wmic /namespace:\\root\default Path SystemRestore Call enable “C:\”

# Este comando establece el espacio de disco para los puntos de restauración en un 25%
# This command sets the disk space for restore points to 25%

vssadmin resize shadowstorage /on=c: /for=c: /maxsize=25%

# Este comando ejecuta un punto de restauración llamado "My Restore Point"
# This command executes a restore point called "My Restore Point"

cmd.exe /k "wmic.exe /Namespace:\\root\default Path SystemRestore Call CreateRestorePoint "MyARestore Point", 100, 7"


To check it

    Command: vssadmin list shadows


by GoN | Published: Nov 1, 2021 | Last Updated:

WINDOWS. PS. DNS Export

Purpose

How to make a script to export the DNS information

Steps

Add the following commands to a *.PP1 file:

Import-Module grouppolicy

$date = get-date -format d.M.yyyy

 $DNSServer="MYDC"

$Zones = @(Get-DnsServerZone -ComputerName $DNSServer)

$Data = @()

ForEach ($Zone in $Zones) {

                $nombrefile = $date + $Zone.ZoneName + ".dns.bak"

                dnscmd /zoneexport $Zone.ZoneName backup\$nombrefile

                 Copy-Item C:\Windows\System32\dns\backup\$nombrefile \\midomain\datos\Backups\DNS

}

$PSEmailServer = "10.10.11.10"

Send-MailMessage -From no-reply@myhome.loca -To infrastructures@myhome.local -Subject "mycompay. Backups semanal DFS Mydom.LOCAL" -Body "Finalizada la copia de Backups de DFS en el servidor XXXXX"

 by GoN | Published: Nov 1, 2021 | Last Updated: