Powershell – Linux – Invoke Using Command Argument

Background There are a couple of ways to invoke Powershell in Linux. Options Here are a couple of Options:- -File -Command Payload - File Syntax Sample Payload - Command Outline To get username Environment::UserName Syntax Sample Hello World Output Output - Image Output - Text Explanation We printed out our username Environment Variables and $PSVersionTable … Continue reading Powershell – Linux – Invoke Using Command Argument

Install Powershell on Linux/CentOS

Background Back playing around with a Linux box and wanted to see if it is any easier for me to understand the steps for installing Powershell. Outline Configure Source Repositories Review available Microsoft Repository for your OS/Version ( https://packages.microsoft.com/config/rhel/ ) Redhat Repository - Local Review "Local" Redhat Repository Is Microsoft repository registered? If Microsoft Repository … Continue reading Install Powershell on Linux/CentOS

Powershell – Error – “The property …. cannot be found on this object. Verify that the property exists.”

Background Playing around with Powershell and ran into an error that one should avoid through defensive programming. Error Error - Image Error - Text Outline We will create a few standalone objects using PSCustomObject Add created objects into an array Iterate through the array Access each object Retrieve property Because our object's properties are created … Continue reading Powershell – Error – “The property …. cannot be found on this object. Verify that the property exists.”

Win OS – Get Domain Information – Using WMI

Background Using WMI, Let us get the short domain name Windows Management Instrumentation (WMI) Script Outline Issue "Get-WmiObject -Class Win32_NTDomain" Capture result of Get-WmiObject in a object Result is actually a list Iterate through the list Each time place list node in an object Here are the important attributes DnsForestName DomainName DomainControllerName DomainControllerAddress Roles Powershell … Continue reading Win OS – Get Domain Information – Using WMI

PowerShell – Network Command – “Test-NetConnection”

Background Continuing with preparing for our planned Network work. Lineage PowerShell – Network Command – "Get-NetAdapter" Link Test-NetConnection Outline The Test-NetCommand provides basic network connection testing over the TCP Protocol. Exercises Exercise - Basic Outline Basic network connectivity test TCP Network Port Test Network Port Number specified as numeric "Common TCP" Port Port Test Diagnostic … Continue reading PowerShell – Network Command – “Test-NetConnection”

PowerShell – Network Command – “Get-NetAdapter”

Background Have a few days of network diagnostic work ahead. And, so let us prepare and go through our requirements worksheet. Get-NetAdapter Outline The Get-NetAdapter command lists the network adapter on our machine. Syntax Sample Output Output-Image Output-Text Explanation I am on a laptop using a wireless connection The key points for me are My … Continue reading PowerShell – Network Command – “Get-NetAdapter”

Raimund Andrée – NTFSSecurity – Usage Scenario – Day 1

Background Now that we have downloaded and installed Raimund Andrée's NTFSSecurity in one of the standard PowerShell Module's folder, we are ready to write a little test code and see how well it works. Code Script getNTFSPermissions.ps1   Sample Get Permissions for Excel files Code Output Get Permissions for Scheduled Tasks ( Local to machine) Code … Continue reading Raimund Andrée – NTFSSecurity – Usage Scenario – Day 1

SQL Server – Query Plan – Which queries on a Specific Column

Background As a quick follow up to our last post which looks for a specific table in the Query Plan, let us be a bit more succinct and look for a specific column.   Code Look for all Column References   Output:     Look for Column Reference in specific Where Clauses In this new example, we … Continue reading SQL Server – Query Plan – Which queries on a Specific Column

Powershell – Running Powershell Scripts embedded within folders that have spaces in their name

Background This is a stupid problem to have, but I have it. I created a long folder name that has a space between two words.   PowerShell Script     Error Now when I try to run to run a power script, I get an error message: Syntax:   Error Message:   Textual:     … Continue reading Powershell – Running Powershell Scripts embedded within folders that have spaces in their name

Powershell – Writing out Array Elements

  Background As I went back and started closing out the many Google Chrome Windows and Tabs that I had opened, I took another look at a blog post titled "A Taste of PowerShell - String Manipulation: Splitting and Joining Strings" -http://tasteofpowershell.blogspot.com/2009/08/string-manipulation-splitting-and.html .   Introduction The Blog post has a very concise code that was quite … Continue reading Powershell – Writing out Array Elements