miércoles, 20 de noviembre de 2019

Windows. Ping with time


Purpose

Do a ping with tag time

Steps

Open PowerShell console

Command1:

 
ping.exe -t 8.8.8.8|Foreach{"{0} - {1}" -f (Get-Date),$_} 


Command1:

 
ping.exe -t 8.8.8.8|Foreach{"{0} - {1}" -f (Get-Date),$_} >> c:\temp\connectividad.log



Check Windows
by GoN | Published: November 20, 2019 | Last Updated:

domingo, 6 de octubre de 2019

WINDOWS. PS. Check reboot if needed


Purpose

How to know if the Windows O.S need reboot

Steps

Command:

 Get-DscLocalConfigurationManater







Check Windows 2016
by GoN | Published: October 6, 2019 | Last Updated:

WINDOWS. GPO. USB Bloqued


Purpose

How to blo
cked a usb windows port by GPO


Steps



Run gpmc.msc to acces to GPO console.

Modify the next parameters:




Some time, some laptops brands it is possible that Windows O.S detected his local hard disk like a usb disk.




Check Windows 2016
by GoN | Published: October 6, 2019 | Last Updated:

martes, 11 de junio de 2019

LINUX. Update - upgrade System

1. Privilege escalation or elevation

su - root  

or put sudo after commnands like 

sudo apt-get update

2. Execute updates:
apt-get update


3. Upgrade packatges

apt-get upgrade -y 



4. Upgrade distribution
apt-get dist-upgrade -y


5. If you need restart the system

reboot



Check Check Debian 9 / Ubuntu 18.04.02
by GoN | Published: Juny 11 2019 | Last Updated:

lunes, 8 de abril de 2019

domingo, 10 de marzo de 2019

WINDOWS. PS. DFS commands for share folders

Purpose

To know some power Shell DFS commands
and examples.

Steps

Command:

 $selected_dfs = Read-Host 'Write DFS Resource (EX: "\\domain.local\RECURSOS\IT" or "\\domain.local\RECURSOS\*") :'

Get-DfsnFolder $selected_dfs



Other example: "Get-DfsnFolder -Path "\\Contoso\AccountingResources\*""

Command:

Get-DfsnFolderTarget \\dominio.local\RECURSOS\it



Command:

Get-DfsnRoot



Command:

Get-DfsnFolder -path \\dominio.local\recursos\*  | Select-Object -Property path, description




Command:

dfsutil /root:\\dominio.local\recursos /View









Check Windows 2012R2
by GoN | Published: March 10 2019 | Last Updated:

WINDOWS. GPO. Grained password. Some password policy.

Purpose


Fortify the passwords of  administrators or privileged users without using the default Windows passwords policy.


Steps




This securicurity implementation only apply to members of groups, in this case "XX_admins_password"


Send one email inform that your password expired:


#Primary mail variables
$SmtpServer="10.10.10.10"
$From="ADMPasswordExpiry@Midomain.es"

#Starting expire check in days
$expireindays=10

#Getting users array from all AD
$users=Get-ADuser -Properties Name, PasswordNeverExpires, PasswordExpired, PasswordLastSet, EmailAddress -Filter *

#Loop for checking $users array in search of Fine Grained Passwords accounts to send them expiry passwords advise mails
foreach ($user in $users) {

    #Get the Name attribute for message purposes
    $Name = (Get-ADUser $user | ForEach-Object { $_.Name })

    #Check if users have default password policy of fine grained password policy
    $Check=Get-ADUserResultantPasswordPolicy $user


    #Condition for discard users that have default domain policy and execute the script only for the remaining ones   
    if (!$check) {


    } else {

        #Setting expiration date parameter for user
        $passwordSetDate = (Get-ADUser $user -properties * | ForEach-Object {$_.PasswordLastSet})
        $maxPasswordAge = (Get-ADUserResultantPasswordPolicy $user | ForEach-Object {$_.maxPasswordAge})
        $expireson=$passwordSetDate + $maxPasswordAge

        #Getting script execution day date
        $today=Get-Date

        #Obtaining remaining days to expire password for user
        $daystoexpire=(New-TimeSpan -Start $today -End $Expireson).Days

        #Obtaining mail attribute from user
        $emailaddress=$user.EmailAddress

        #Condition that executes the mail advise if remaining days for password expiration are less than $expireindays variable and if is not expired (0 days remaining)
        If (($daystoexpire -ge "0") -and ($daystoexpire -lt $expireindays)) {

                $EmailBody="Te quedan $daystoexpire dias para cambiar la contraseña de tu usuario $name."

            }

            #Email subject
            $EmailSubj="Aviso de caducidad de password de tu usuario administrador"

            #Create and send an email object
            $SMTPClient = New-Object Net.Mail.SMTPClient($SmtpServer)

            $emailMessage = New-Object System.Net.Mail.MailMessage

            $emailMessage.From = "$From"

            Foreach($EmailTo in $emailaddress)
                {
                    $emailMessage.To.Add($EmailTo)
                }

            $emailMessage.Subject = "$EmailSubj"
            $emailMessage.Body = "$EmailBody"

            $SMTPClient.Send($emailMessage)

                              
                    }

                    Else {
           
            #No pending password expire

                    }


    }

}



Check Windows 2012R2
by GoN | Published: March 10 2019 | Last Updated:

martes, 26 de febrero de 2019

WINDOWS. Install Nano Server

Purpose

Nano Server installation process, Deploying Nano Server as a Hyper-V guest

Steps




Command:  Import-Module NanoServerImageGenerator.psm1



Command:

New-NanoServerImage -Edition Standard -MediaPath D: -BasePath .\Base -TargetPath .\NanoVM\NanoServerVM.vhd -ComputerName TestNano -DeploymentType guest


Notes: "-DeploymentType Guest or host. Use guest to configure the VHD for use as a guest on another host."






VM



Hyper-V












Network





Check Windows 2016
by GoN | Published: Febrary 26 2019 | Last Updated:

sábado, 16 de febrero de 2019

WINDOWS. PS. Installation TimeStamp O.S.

Purpose

Know how old is the system installation.

Steps

Command: (Get-CimInstance -Class Win32_OperatingSystem).InstallDate



Command: New-TimeSpan -Start (Get-CimInstance -Class Win32_OperatingSystem).InstallDate


Check Windows 2012R2
by GoN | Published: Febrary 18 2019 | Last Updated:



viernes, 25 de enero de 2019

WEB. Track the continuity service of important companies online

All companies they track
https://downdetector.com/companies




Exchange Online outage map
https://downdetector.com/status/exchange/map/


Verizon
https://downdetector.com/status/verizon

etc...


by GoN | Published: January 25 2019 | Last Updated:

jueves, 24 de enero de 2019

LINUX. Antivirus CLAMAV

Purpose

Install and protect my Linux operating system from virus. 


We need have administrator  privileges

Steps

Command: "sudo apt-get install clamav clamav-daemon"

 This command can long very minutes




Command: "sudo freshclam" update antivirus


If there are errors:


You need stop this service firts


Command: "sudo /etc/init.d/clamav-daemon start"  start antivirus


Command:
"sudo /etc/init.d/clamav-freshclam start"



To run the software:

 Command: "sudo clamscan"

To scheduler

1. Made a directory for files in quarentine 


2. Use crontab

I choose 1 option

Insert this commands:


This sentence excute te antirus every day at 22:00 and move to /tmp/VIRUSCUARENTENA the suspects files

More info: https://www.clamav.net/


Check in Linux Mint 19.1 Cinnamon & Ubuntu 
by GoN | Published: January 24 2019 | Last Updated: Augost 8, 2020