Working with PowerShell Modules, Parameters, Variable, Objects, Commands Script and Syntax.

 Working with PowerShell Modules, Parameters, Variable, Objects, 

Commands Script and Syntax running on WS2K19 by VMware Workstation

Check the current PowerShell version table in this Windows Server is 5.1 


Work with PowerShell Modules:
This is done by utilizing a Command "Import-Module -Name". 
Import-Module has various parameters are available. 


We can see by click through them, there are a few simple ones:
First ones is "-Global" which will import it globally. 

We can go back and tab through "-Prefix DEMO" 
and add prefix to the names of actual command that will import it.

Mention the name of the Module "-Name PSDiagnostics"

How do you know the names of the Modules. 
We can use a command "Get-Module" 
and  actually has a property name "-ListAvailable" and press enter. 
This one takes you to the PowerShell Core and look inside to the list of modules are available.

We have the name to the ones which we wish to import in. 
"Get-Module -ListAvailable | Import-Module" 
    We can basically go back and tab through them by entering to every single module. 

Now i can use command "Import-Module -ModuleInfo $module". 

Import-Module PSDiagnostics -Function Disable-PSTrace, Enable-PSTrace

Get-Command *PSTrace*

Get-Command *PS* 

$session = New-PSSession -ComputerName WS2K19-DC01

Get-Module -PSSession $session -ListAvailable -Name PSDiagnostics

Import-Module PSDiagnostics -Prefix DEMO -PassThru 

Get-Command *DEMO* 

Explore Help: 
Get-Help 

Now I just to utilize the "Get-Help Format-Table OR ft" commands 
so it's returns back to the same value 
      "Get-Help -Name Format-Table"
      "Format-Table -?" 
      "Help Format-Table" It gives a expanded help information 
      "Man Format-Table"

 "Get-Help Format-Table | Out-Host -Paging" 
    "Get-Help Format-Table -Detailed" 
   -Full
   -Examples
   -Online
   -Parameter * 

If I try a different function "Get-Help Get-ChildItem -Parameter *" 
[Same principle applies to that specific function]
                                                          -Parameter GroupBy 
[It's just return the detailed to that specific function] 

Get-Help about_* 

"Get-Help Add-Member -Full | Out-String -Stream | Select-String -Pattern Clixml"

"Get-Help -Name remoting" 

We can also save a specific help information "Save-Help" option 
if we need too and it can ask you for a specific path.

We can specify the module that I wish to download for specific command too "
$modulename = "PSDiagnostics"

$module = Invoke-Command -ScriptBlock { Get-Module -Name $modulename -ListAvailable }
    $module 

Understand terse commands & cmdlet syntax:
Get-Command | Format-Table

Get-Command Get-ChildItem 
gcm Get-ChildItem  

Get-Alias 

Get-Command | Where-Object { $_.parametersets.count -gt 2 } | Format-List Name 
gcm | ? { $_.parametersets.count -gt 2 } | fl Name

Write-Output "Test Message"
echo "Test Message"

Get-Process [gps]

Utilize Variables:
$var1 = "Test Value 1"
    $var1 
    Write-Host $var1

$var2 = Get-ComputerInfo [Loading]

$var2 [Computer Info shown in Details] 

$var2.BiosFirmwareType 

$var2.TimeZone 

Now create a Static Value from Get-Service 
    $var3 = "WSearch" 
    $var3 
    Get-Service -Name $var3 

Get-Service | Sort-Object -Property Status

Get-Service | Where-Object {$_.Status -eq "Running" }

Get-Service | Where-Object {$_.Status -eq "Running" } | Select-Object DisplayName

Get-ChildItem Env: [This show all the Environment Variables]

$env:SystemRoot
     $env:DEMO = "My Text Value"
     Get-ChildItem Env: 

$varTest = "1"
    $varTest
    [int32]$varTest
    [float]$varTest
    [string]$varTest
    [boolean]$varTest 

Understand PowerShell Objects:
Get-Service 

Get-Service -ServiceName 'DnsCache' | Get-Member

Get-Service -ServiceName 'DnsCache' | Get-Member -MemberType Property

Get-Service -ServiceName 'DnsCache' | Select-Object -Property 'StartType'

Get-Service -ServiceName 'DnsCache' | Get-Member -MemberType 'AliasProperty'

$svc = Get-Service -ServiceName 'DnsCache'
    $svc

$svc.Name
    $svc.RequiredServices

Get-Service -ServiceName 'DnsCache' | Get-Member -MemberType 'Method'

Get-Service -ServiceName * | Select-Object -Property 'Status', 'DisplayName' | 
Sort-Object -Property 'Status' -Descending


Comments