Category: Scripting

VMware vCenter Server 6.0 – Verify the Status of Critical Services Locally

The script below will query the status of the service(s) specified in “C:\Scripts\VMware vCenter Server\Verify_Critical_Services.txt” on the local server. The output of the script will provide the name and status of the service(s) in a formatted list for your viewing. Additionally, it is recommended that the following services be queried as they are critical to the proper functioning of VMware vCenter Server 6.

  • VMware VirtualCenter Server (vpxd)
  • VMware Inventory Service (invsvc)
  • VMware vSphere Web Client (vspherewebclientsvc)

<#
.SYNOPSIS
This script will provide the name and status of the service(s) defined in “C:\Scripts\VMware vCenter Server\Verify_Critical_Services.txt”
.DESCRIPTION
This script will automate the process of providing the status of critical VMware vCenter Server 6 service(s) on the local server
.EXAMPLE
N/A.
.AUTHOR
Written by Noel Enrique Alvarez on Wednesday, November 22, 2017.
#>

#Define the service(s) to query
$Services = Get-Content “C:\Scripts\VMware vCenter Server\Verify_Critical_Services.txt”

#Query the status of the service(s) in “C:\Scripts\VMware vCenter Server\Verify_Critical_Services.txt”
ForEach ($Service in $Services)
{Get-Service $Service |
Format-List -Property Name, Status}


Red Hat Enterprise Linux 7 – Sample Kickstart File

Red Hat Enterprise Linux (RHEL) 7 provides a kickstart file that you may use to automate the installation of RHEL. Below is a sample kickstart file (ks.cfg) that you may modify for the automated installation of RHEL.

 

#version=DEVEL
# System authorization information
auth –enableshadow –passalgo=sha512
# Use CDROM installation media
cdrom
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot –enable
ignoredisk –only-use=sda
# Keyboard layouts
keyboard –vckeymap=us –xlayouts=’us’
# System language
lang en_US.UTF-8

# Network information
network –bootproto=static –device=eth0 –gateway=x.x.x.x –ip=x.x.x.x –nameserver=x.x.x.x,x.x.x.x –netmask=x.x.x.x –ipv6=auto –activate
network –hostname=rhel01

# Root password
rootpw –iscrypted $6$fa
# System services
services –disabled=”chronyd”
# System timezone
timezone America/New_York –isUtc –nontp
user –name=tuser –password=$6$zn

iscrypted –gecos=”Temporary User”
# X Window System configuration information
xconfig –startxonboot
# System bootloader configuration
bootloader –append=” crashkernel=auto” –location=mbr –boot-drive=sda
# Partition clearing information
clearpart –all –initlabel –drives=sda
# Disk partitioning information
part /boot –fstype=”xfs” –ondisk=sda –size=500
part swap –fstype=”swap” –ondisk=sda –size=4096
part pv.614 –fstype=”lvmpv” –ondisk=sda –size=46603
volgroup centos –pesize=4096 pv.614
logvol / –fstype=”xfs” –size=20480 –name=root –vgname=centos
logvol /home –fstype=”xfs” –size=26120 –name=home –vgname=centos

%packages
@^graphical-server-environment
@base
@core
@desktop-debugging
@dial-up
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@input-methods
@internet-browser
@multimedia
@print-client
@x11
kexec-tools

%end

%addon com_redhat_kdump –enable –reserve-mb=’auto’

%end

 


Microsoft Windows PowerShell – Delete DNS A Record

Scripting is a great way to make yourself more efficient as an Information Technology (IT) professional. With that being said, the Microsoft Windows PowerShell script below may be used to automate the deletion of a domain name system (DNS) A record.

<#
.SYNOPSIS
This script will automate the process of deleting a DNS A record.
.DESCRIPTION
This script will automate the process of deleting a DNS A record.
.EXAMPLE
Remove-DnsServerResourceRecord -ZoneName “noelalvarez.net” -RRType “A” -Name “www”.
.AUTHOR
Written by Noel Enrique Alvarez on Thursday, December 22, 2016.
#>

#Request the hostname of the server
$HOSTNAME = Read-Host “What is the hostname of the server?”

#Delete the DNS A record
Remove-DnsServerResourceRecord -ZoneName “noelalvarez.net” -RRType “A” -Name “$HOSTNAME” -Force

#End of script


Dell – Get Service Tag Remotely

You may use the Microsoft Windows PowerShell script below to get the service tag of a Dell server, remotely.

<#
.SYNOPSIS
This script will automate the process of determining the service tag of a Dell server.
.DESCRIPTION
This script will query the server you specificy for it’s service tag.
.EXAMPLE
wmic /user:administrator /node:hostname bios get serialnumber.
.AUTHOR
Written by Noel Enrique Alvarez on Monday, December 05, 2016.
#>

#Request the domain name
$– USERNAME = Read-Host “What is the username of the administrator account?”

#Request the hostname of the server
$HOSTNAME = Read-Host “What is hostname of the server?”

#Get the service tag
wmic /user:$– USERNAME /node:$HOSTNAME bios get serialnumber

#End of script


Microsoft Windows PowerShell – Add a Domain User to a Group

You may use the Microsoft Windows PowerShell script below to remotely add a domain user to the specified group of the server you choose.

<#
.SYNOPSIS
This script will add a domain user to a group on a server.
.DESCRIPTION
This script will automate the process of adding a domain user to a group on a server.
.EXAMPLE
N/A.
.AUTHOR
Modified by Noel Enrique Alvarez on Friday, December 02, 2016.
#>

#Request the domain name
$DOMAIN = Read-Host “What is the domain?”

#Request the username
$– USERNAME = Read-Host “What is the username?”

#Request the hostname of the server
$SERVER = Read-Host “What is the hostname of the server?”

#Request the name of the group
$GROUP = Read-Host “What is the name of the group (i.e. Administrators)?”

([ADSI]”WinNT://$SERVER/$GROUP,group”).psbase.Invoke(“Add”,([ADSI]”WinNT://$DOMAIN/$– USERNAME”).path)


Microsoft Windows Server 2012 R2 – Start a Service

You may use the Microsoft Windows PowerShell script below to start a service, remotely.

<#
.SYNOPSIS
This script will a service on the specified server.
.DESCRIPTION
This script automates the process of starting a service.
.EXAMPLE
N/A.
.AUTHOR
Written by Noel Enrique Alvarez on Thursday, March 03, 2016.
#>

#Request the hostname of the server and the name of the service
$SERVER = Read-Host “What is the hostname of the server?”
$SERVICE = Read-Host “What is the name of the service?”

#Request the status of the service
get-service -computername $SERVER | where-object {$_.name -eq “$SERVICE”}

#Pause for (5) seconds
Start-Sleep 5

#Start the service
get-service -name $SERVICE -computername $SERVER | set-service -status running

#Pause for (5) seconds
Start-Sleep 5

#Request the status of the service
get-service -computername $SERVER | where-object {$_.name -eq “$SERVICE”}

#End of script


Microsoft Windows Server 2012 R2 – Verify Service Status

You may use the Microsoft Windows PowerShell script below to verify the status of the service you specify, remotely.

<#
.SYNOPSIS
This script will provide the status of a service on the specified computer.
.DESCRIPTION
This script automates the process for verifying the status of a service.
.EXAMPLE
N/A.
.AUTHOR
Written by Noel Enrique Alvarez on Tuesday, November 24, 2015.
#>

#Request the hostname of the server
$SERVER = Read-Host “What is the hostname of the server?”

#Request the name of the service
$SERVICE = Read-Host “What is the name of the service?”

#Query the status of the service
get-service -computername $SERVER | where-object {$_.name -eq “$SERVICE”}

#End of script


Microsoft Windows Server 2012 R2 – Verify Network Interface Card Status

You may use the Microsoft Windows PowerShell script below to verify the network interface card (NIC) status on servers running the Microsoft Windows Server 2012 R2 operating system. Additionally, the output of the script will be displayed in a graphical user interface (GUI).

<#
.SYNOPSIS
This script will verify the network interface card status of the selected servers.
.DESCRIPTION
This script will automate the process of verifying the network interface card status of the selected servers.
.EXAMPLE
N/A.
.AUTHOR
Written by Noel Enrique Alvarez on Thursday, August 05, 2016.
#>

#Verify the network adapter status of the branch servers
Get-NetAdapter -CimSession (Get-Content “C:\Scripts\Branch Servers.txt”) -Name NIC1, NIC2 | select SystemName, Status, MediaConnectionState | Out-GridView -Title “Network Adapters”

#End of script

 


Microsoft Windows Server 2012 R2 – Configure Hard Disks

The Microsoft Windows PowerShell script below may be used to automate the process of configuring hard disks in Microsoft Windows Server 2012 R2.

<#
.SYNOPSIS
This script will configure hard disks.
.DESCRIPTION
This script will automate the process of configuring hard disks.
.EXAMPLE
N/A.
.AUTHOR
Written by Noel Enrique Alvarez on Thursday, October 13, 2016.
#>

#Request the disk number
$Disk_Number = Read-Host “What is the disk number?”

#Request the disk letter
$Disk_Letter = Read-Host “What is the drive letter?”

#Request the disk size
$Disk_Size = Read-Host “What is the drive size?”
$Disk_Size = $Disk_Size -as [int]
$Disk_Size = $Disk_Size * “1GB”

#Initialize the disk
Initialize-Disk -Number $Disk_Number

#Pause for (5) seconds
Start-Sleep 5

#Configure the disk
New-Partition -DiskNumber $Disk_Number -DriveLetter $Disk_Letter -Size $Disk_Size
Format-Volume -DriveLetter $Disk_Letter -FileSystem NTFS -Confirm:$False
&”.\configure_disk_settings.ps1″

#End of script

 


Dell Compellent – Verify the Enterprise Manager and Enterprise Services Agent Service Status

You may use the Microsoft Windows PowerShell script below to remotely verify the Enterprise Manager and Enterprise Services Agent Service status. These services are essential to a healthy Enterprise Manager infrastructure.

<#
.SYNOPSIS
This script will provide the status of the Enterprise Manager service on EM01. Additionally, it will provide the status of the Enterprise Services Agent Service on servers utilizing the Enterprise Manager Server Agent.
.DESCRIPTION
This script will automate the process of providing the status of the Enterprise Manager service on EM01. Additionally, it will automate the the process of providing the status of the Enterprise Services Agent Service on servers utilizing the Enterprise Manager Server Agent.
.EXAMPLE
N/A.
.AUTHOR
Written by Noel Enrique Alvarez on Friday, September 30, 2016.
#>

#Query the status of the Enterprise Manager service on EM01
Get-Service -ComputerName EM01 | Where-Object {$_.name -eq “EnterpriseManagerDataCollector”}

#Query the status of the Enterprise Services Agent Service on servers utilizing the Enterprise Manager Server Agent
Get-Service -ComputerName SERVER01 | Where-Object {$_.name -eq “CompellentEMServerAgent”}
Get-Service -ComputerName SERVER02 | Where-Object {$_.name -eq “CompellentEMServerAgent”}
Get-Service -ComputerName SERVER03 | Where-Object {$_.name -eq “CompellentEMServerAgent”}

#End of script