Get Computer Fully Qualified Domain Name ( Using Powershell )

Background Recently I needed to confirm a remote's computer fully qualified domain name. Options GUI Win OS Outline Access Control Panel \ System and Security \ System The computer name will be listed Group Box:- Computer name, domain, and workgroup settings Item:- Full Computer Name Images Image - View basic information about your computer Console … Continue reading Get Computer Fully Qualified Domain Name ( Using Powershell )

Powershell:- Send Email – Sample Script

Background Yesterday, I had a script that I could not get email notification to go out on. Rather than installing Blat or other email command line tools, I opted to use PowerShell. Code Powershell Script Output Output - Image Output - Text Source Code GitLab PowerShell - Email - Send Link   Referenced Work Microsoft … Continue reading Powershell:- Send Email – Sample Script

Active Directory:- Get Group Members using Powershell ( Get-ADGroupMember )

Background I need to query Active Directory ( AD ) and get a listing of group members matching a specific criteria. GUI Active Directory Users and Computers Active Directory Users and Computers MMC is a very capable tool for querying AD. Console Powershell - Active Directory Get-ADGroupMember Here is how I will do so using … Continue reading Active Directory:- Get Group Members using Powershell ( Get-ADGroupMember )

Powershell:- Repeat Character

Background A few weeks ago, I was in a jam. I wanted to draw a line on my console to separate out two sections of output. It seems terrible inefficient to use Write-Output("----------------------------------------"). I preferred something like Write-Output(repeatChars('-', 80)). Code Here is stolen code that I have to come back and properly attribute ( give … Continue reading Powershell:- Repeat Character

Powershell:- Raising an ArgumentException

Background Good software engineers engage in defensive development. As opposed to offensive practices. Code In this post, we will employ .Net's System.ArgumentException to offer examples of how to better help the developer know why an application is failing. Outline Function:- calculatorGraceful If operation is equal and divisor is 0 If exceptionType is 1 throw (New-Object … Continue reading Powershell:- Raising an ArgumentException

Powershell:- Import-CSV – Filtered List

Background Employing Import-CSV to read in a datafile. My use case will work better if I am able to comment out certain entries' as opposed to outright removing them from the datafile. Datafiles Datafile - Number of Lines - 11 Script Outline Read File $listofPersons = @(Import-CSV -Path $filename -Delimiter "|"); Filter List Construct Discard … Continue reading Powershell:- Import-CSV – Filtered List

Powershell:- Import-CSV And Array Subexpression

Background Experienced a little error using Import-CSV. Error PropertyNotFoundException Error Image Error Text   Datafiles Datafile - Number of Lines - 01   Datafile - Number of Lines - 02   Code Original   Revision   Use Scenario Original Code File - Number of Lines - 2 Invoke Output Output - Image Output - Text … Continue reading Powershell:- Import-CSV And Array Subexpression

Powershell:- Get-NetTCPConnection – Error – “No MSFT_NetTCPConnection objects found with property”

Background Dealing with them insomnia nights and you run into a trouble. And, you say I have other problems, I will come back and deal with this in the morning.   Get-NetTCPConnection Base To get a quick list of TCP Connections, you issue "Get-NetTCPConnection" Command Sample Output Image   SQL Server ( TCP Port 1433 … Continue reading Powershell:- Get-NetTCPConnection – Error – “No MSFT_NetTCPConnection objects found with property”

PowerShell:- Out-GridView -PassThru | Set-Clipboard

Background Yesterday, I found myself struggling with a database project. I thought let me capture some metadata, view it in a grid view and I will have more to go with.   Clipboard Captured the data into a data table, pipelined it into GridView. Got a good thing going. As always got greedy. Thought to … Continue reading PowerShell:- Out-GridView -PassThru | Set-Clipboard

PowerShell:- Write-Verbose

Background Let us take a quick look at PowerShell's Write-Verbose command.   Samples Outline In this post we have a couple of sample PowerShell Scripts. Sample -01 Add two numbers Display result of adding the numbers Sample -02 Added write-verbose to enable verbose code logging Sample -03 Added [CmdletBinding()] to enable "cmdlet-style parameter binding"   … Continue reading PowerShell:- Write-Verbose