Skip to content

Instantly share code, notes, and snippets.

@sandeep-sr
sandeep-sr / powershell_SCCM_client_status_version.ps1
Created June 3, 2021 15:36
powershell - script to check SCCM client status,version & sitecode
<#
.Synopsis
This script will check SCCM client status,version & sitecode.
If the site code is not cloudwiki1 it will assign/change to cloudwiki1
#>
Start-Transcript c:\temp\versionlog.txt
$r="Running"
@sandeep-sr
sandeep-sr / Unassign_all_user_mapings_from_a_specific_pool.ps1
Created July 8, 2021 10:20
Unassign all users from a specific pool
<#
.Synopsis
Unassign all users mappings from a specific pool
.Details required to run the script
1) Enter the Portal URL for $tenanturl
2) Enter Credentials information in $ADCredentials section which need below inputs
3) You will get a prompt to input pool id of the vm's
.Limitations
@sandeep-sr
sandeep-sr / NSX_Host_Prep_Report.ps1
Created July 4, 2021 10:25
find the clusters are not in ready state for NSX-V
<#
.Synopsis
find the clusters are not in ready state
.Note
Copy the vcenter names into a text file named "vcenter" and place it into C:\temp before executing the script
#>
Get-Module -listavailable *vm*|Import-Module
Get-Module -listavailable *nsx*|Import-Module
$cred=Get-Credential
$redColor = "#FF0000"
@sandeep-sr
sandeep-sr / User_To_VM_Mapping.ps1
Created June 19, 2021 17:33
Horizon Cloud DAAS REST API - VM to User mapping PowerShell Script
<#
.Synopsis
VM to User mapping Powershell Script
.Details required to run the script
1) Enter the Portal URL for $tenanturl
2) Enter the Domain Name for $Domain
3) Change the Path of CSV file in $csvfile
4) Enter Credentials information in $ADCredentials section which need below inputs
@sandeep-sr
sandeep-sr / powershell_ip_increase.ps1
Created June 3, 2021 15:49
powershell - simple powershell operators we can increase the last digits in an IP
#Helps in increasing the IP based on the input
$IP="10.1.2.3"
$split=$IP.Split(".",4) | Select -Index 3
[int]$lastpart=$split
$ipnew=($ip.split(".",4)|select -index 0,1,2) -join "."
$add=$lastpart+25
$ip25th=$IPnew +"." +$add
Write-Output "$ip25th"
@sandeep-sr
sandeep-sr / powershell_find_ad_disabled_accounts.ps1
Created June 3, 2021 15:48
powershell - find disabled ad user accounts
Import-Module Active*
$userdata=get-content c:\temp\useraccounts.txt
foreach($user in $userdata)
{
try
{
$Disabled=(Get-ADUser -Identity $user).Enabled
if($Disabled -match "False")
{
@sandeep-sr
sandeep-sr / powershell_clear_temp_files.ps1
Last active June 3, 2021 15:46
powershell - useful script to clear temporary files before start patching the windows servers to make some space
#This script can be used to to clear un used space of C:\ in windows servers
#once the task is completed it will send a mail to the added in $msg.To.Add
#please update your own smtp server address
#enter the servers suppose to release un-used space in 123.txt file (ex--c:\temp\123.txt)
#Create a folder named Cleanupreports in C:\temp
#Script assumes delprof is already installd in all the servers
$Path = "C:\temp\Cleanupreports\"
@sandeep-sr
sandeep-sr / powercli_capacity_report.ps1
Created June 3, 2021 15:45
powercli - capacity report
#import vmware powershell modules
Get-Module *vm*|import-module
#Connect to vCenter
connect-viserver vcentername.thecloudwiki.com -ea silentlycontinue
#Get the VM details
$vm=(Get-View -ViewType "Virtualmachine" -Filter @{"Runtime.PowerState" ="poweredOn";"Config.GuestFullName"=".*windows*.*"}).name
$percentWarning = 15;
$percentWarning = 15;
$percentCritcal = 10;
$percent50 = 50;
@sandeep-sr
sandeep-sr / powershell_sccm_server_status.ps1
Created June 3, 2021 15:38
powershell - SCCM Check for Server online/offline, Servers presents in AD or not, Service status, Site Code and SCCM client installed or not
$r="Running"
$servers=get-content "C:\temp\SCCM\servers.txt"
$Name = "SCCM_Serv.html"
$report = "C:\temp\SCCM\" + $Name
$header = "
<html>
<head>
@sandeep-sr
sandeep-sr / powercli_delete_multiple_vms.ps1
Created June 3, 2021 15:29
powercli - Delete multiple VM’s
Get-Module -ListAvailable *vm*|Import-Module
$cred=Get-Credential
Connect-VIServer vcenter02 -Credential $cred
$deletevmlist=Get-Content C:\temp\delete.txt
foreach($deletevm in $deletevmlist)
{
write-output ("$deletevm is deleting...")
get-cluster cluster02|get-vm $deletevm |Remove-VM -DeletePermanently -Confirm:$false -RunAsync| out-null
Start-Sleep 10
}