Menu

Virtual Geek

Tales from real IT system administrators world and non-production environment

Blog posts : "Powershell"

Automating Windows VM Cloning and sysprep on Nutanix with PowerShell

One of my friend asked for a PowerShell script for Nutanix Windows virtual machine cloning and configuration. This PowerShell script automates the process of cloning virtual machines and joining them to a domain. It uses the Nutanix PowerShell module to interact with the Nutanix cluster and clone vi…

Read more

Parallel Ping and Port Testing in PowerShell Using Runspaces

In this article, I demonstrate how to test network connectivity for a list of computer names or IP addresses using PowerShell. Each target system is tested for ICMP reachability (ping) and TCP connectivity on port 445, which is commonly used for SMB.

The core logic is implemented in a custom func…

Read more

Get PowerShell Cmdlet Parameter Enum Values Easily

Enumeration is the action of mentioning a number of things one by one, often to count them or describe them but it has specific meanings in computer science, data types like enum for named constants. 

In the PowerShell to list the enumeration information for a parameter, you will need to use elem…

Read more

Automating Linux VM Cloning and IP Configuration on Nutanix with PowerShell

This simple PowerShell script clones Nutanix Linux virtual machines. To use this script, first download and install the PowerShell cmdlets from Nutanix Prism Central. You can find the installed plugin folder under C:\Program Files(x86)\Nutanix folder. From there you can load plugins.

A screenshot of the Nutanix Prism Central web interface dropdown menu under the help icon. The menu highlights options for 'Download Cmdlets' and 'Download nCLI' in a red box, along with links for Update Profile, REST API Explorer powershell, and Sign Out.

After in…

Read more

PowerShell File Renaming: How to Reorder Files Sequentially Using a CSV Map

I recently received a task to rename a bunch of files by changing their numbering in the filename while working on a PowerShell DevOps project. I had multiple Markdown files with numbers at the start of their names, and I needed to change these numbers with the filename based on a mentioned in CSV f…

Read more

High-Performance Network Auditing: Custom Ping and TCP Port Testing in PowerShell .Net Objects

This article dives into the Test-TcpPort function, a compact script that resolves hostnames to IPs, pings for basic reachability, and tests port connectivity with a timeout. I will break down its mechanics in short. At its core, Test-TcpPort leverages .NET's System.Net and System.Net.Sockets namespa…

Read more

Building a Unified Ping and Port Connectivity Report with PowerShell

In this article, I will explore two PowerShell scripts that test network connectivity (Ping) and port availability (Port Query) on multiple computers. I will discuss the scripts, their differences, and how to use them effectively. First Script is used for Synchronous Network Testing. The first scrip…

Read more

PowerShell PSRemoting Fix: Bypassing "Access is Denied" for Privileged Admin Commands

While working with PowerShell Remoting (PSRemoting), I was able to successfully connect to a remote machine using Enter-PSSession, but any administrative command—such as resetting the local Administrator password—failed with:

System error 5 has occurred.
Access is denied.

Even though the …

Read more

PowerShell Remoting Access is Denied: How to Fix PSRemoting for Administrators Group Accounts

After successfully configuring Microsoft PowerShell PSRemoting, I was able to login with local Administrator user without any issue. But after creating another user, adding it to Administrators group then logging with it was throwing error message of Access is denied.

Screenshot of PowerShell showing the Enter-PSSession failure with the error message: 'Access is denied' for a local administrator account (vmadmin) trying to connect to a remote server 10.0.0.4 local administrators.

PS VM02 > Enter-PSSess…

Read more

Bypass the Domain Wall: How to Enable PSRemoting WinRM in a Workgroup Environment

This is very simple and easy instructions to configure PowerShell PSRemoting WinRM on Windows system which is not joined into domain (Basically they are in workgroup). On the the first system login and and open PowerShell as administrator and Run below commands to configure PowerShell Remoting. 

Read more

Broadcom PowerCLI: Building a GUI to Check VMware HA Admission Control Compliance

This PowerCLI GUI script I have written to audit VMware ESXi clusters high availability (HA) inside vCenter Server. This script validates below ideal configuration is defined on the cluster and tells me whether configuration is correct with green tick and non-compliant with red cross.

Note: This …

Read more

The PowerShell Sorting Trap: Why 10 Always Comes Before 2 in Your CSV Data

When sorting CSV data with PowerShell, I observed unexpected results, as shown in the screenshot below. The initial command, Import-Csv C:\Temp\Numberings.csv, shows that the numbers in the CSV are out of sequence. To sort these numbers, I used the simple pipeline command Sort-Object specifying the

Read more

Terraform String Encoding and Decoding with PowerShell

This is another script I have written to encode and decode string for Terraform using PowerShell GUI. These scripts helps me in the live demonstrations and PowerPoint to client about infrastructure as a code. Once script is executed in PowerShell GUI, it looks like below, It helps to Base64 Encode g…

Read more

Self-Signed Certificates Made Easy with PowerShell GUI

I was delivering few demos for Azure Application Gateway client side, I got information, there will be very limited Internet and only specific things will work in the given environment. In one of the demo I wanted to created few Self Signed SSL Certificates for Azure Application Gateway. In the demo…

Read more

How to create byte array in PowerShell

To create a byte array in PowerShell, you can use several methods, depending on whether you want to initialize it with values, specify a size, or convert data like a string or file. The simplest method is to cast an array to the [byte[]] type.

1. Create a byte array with pre-defined values

Thi…

Read more

Streamlining Intune MDM Device Management with Microsoft Graph and PowerShell

As an IT administrator, managing devices in your organization can be a daunting task. With the help of Microsoft Graph and PowerShell, you can automate device management tasks and streamline your workflow. In this article, You can explore how to use PowerShell to connect to Microsoft Graph, retrieve…

Read more

PowerShell & Microsoft Graph API: Automate Full Intune Devices Sync more than 1000 Pagination

This PowerShell script leverages the Microsoft Graph API to synchronize Intune MDM devices. A previous iteration of the script was limited to fetching and syncing only the first 1000 devices due to pagination. To overcome this, the updated script iterates through the @odata.nextLink property, allowi…

Read more

Automate Intune MDM Device Sync: A PowerShell Script for Microsoft Graph API

This PowerShell script demonstrates automated management and synchronization of devices with Microsoft Intune via Microsoft Graph API. Using client credentials to authenticate against Azure AD, it retrieves an OAuth 2.0 token and lists all managed devices in the environment for reporting purpose. 

Read more

PowerShell Create and Export Self-Signed RSA Certificates (PFX, CER, PEM)

This script helps creating SSL Self Signed Certificates and Private/Public key using PowerShell. PowerShell has inbuilt cmdlet command New-SelfSignedCertificate which is used to create proper SSL certificate which doesn't require third party applications such as OpenSSL or similar. There are multipl…

Read more

Monitoring Dell Server Health Using RACADM CLI: Sensor Info from iDRAC

The racadm cli command with getsensorinfo subcommand fetches real-time live hardware sensor data such as temperature, voltage, and power, memory, processor status and other hardware information from a Dell server's iDRAC system. This is very useful to system administrators for monitoring server heal…

Read more

20 blog posts

Blog Search

Page Views

1 4 2 2 8 6 2 9

Archive

Follow me on Blogarama