Windows PowerShell ISE parameters and required services, Finding and Installing Modules, Server Cmdlets & Enable PS Remoting

 Windows PowerShell Functions Script with Syntax,

ISE console for selecting parameters and required

 services, Finding and installing modules, Server

 Cmdlets & Enable PS remoting running on Windows

 Server 2019 Datacenter Edition by VMware

 Workstation.

To get the following service of the Windows Server on PowerShell, 

use the following command:

" Get-Service | Where-object {$_.status -eq "stopped"} "

" Get-Service | Where-object {$_.status -eq "Running"} "

" Get-Service | Get-Member "

" function add
{
$add =[int](2+2)
Write-Output "$add"
}
add "
4 = ##Result-Output

" Get-Service | Stop-Service -whatif " 
Performing the operation

" Get-Service | Stop-Service -confirm "
Perform this action. Say Yes or No?

" ise " ##Press-Enter for opening a new-console

Open a new script and type
" Get-Service -Name Audiosrv "

Highlight the Line & Run Selection (F8) button
Go to view menu for Show Command Add-on

Select Parameters for Get-Service
Computer Name: webserver
Press tick on [Required Services] & copy
Then paste into the console

Run Selection (F8) button
" Get-Service  -ComputerName webserver -RequiredServices "

And If you want to connect PowerShell remotely
File Menu & select New Remote PowerShell Tab

Type Computer name & Username to connect remotely

Working with Output: ##Pipe Formatting 
" Get-Service | Format-List displayname, status, requiredservices "

Get-Service | Out-File C:\Services.txt

Select the Content: 
" Get-Service | Out-File C:\Services.txt "
& Run Selection (F8) button

Get-Service and Export-Csv with Services.csv extension
" Get-Service | Export-Csv C:\Services.csv "

Grid View: ##Pipe Gridview
" Get-Service | Out-GridView "
Run Selection (F8)
[Add criteria]

[Add criteria] to add those list of services

Running PowerShell Remotely

" Get-Command "

" Get-Module -ListAvailable "

" Import-Module -Name applocker "

" Get-Command –Module applocker "

" Get-Module "

" Find-Module "

" Find-Module -Name Get-Vaccinated  | Install-Module "

Installing Package Module Name "Get-Vaccinated"
" Find-Module -Name Get-Vaccinated | Install-Module "

Installing Package Module Name "Azure Resource Management Cmdlets"
" Find-Module -Name AzureResourceManagementCmdlets | Install-Module "

Installing Package Module Name "HM-Monitoring"
" Find-Module -Name HM-Monitoring | Install-Module "

Installing Package Module Name "AWS Tools Open Search Service"
" Find-Module -Name AWS.Tools.OpenSearchService | Install-Module "

" Get-InstalledModule "

Server Cmdlets:
" Get-WindowsFeature "

" Get-WindowsFeature -Name Web-Server "

" Get-WindowsFeature -Name Web-Server | Install-WindowsFeature "

" Get-Help remoting "

" Enable-PSRemoting -Force "

" Get-PSSessionConfiguration "

Clear the Screen " cls "

" $session = New-PSSession -ComputerName localhost "
OR
    " $session = New-PSSession -ComputerName localhost 
-ConfigurationName PowerShell 5.1 "

" $session "

" Invoke-Command -Session $session -ScriptBlock { $PSVersionTable } "

" Enter-PSSession localhost "

" Enter-PSSession localhost " [Press Enter]

" HOSTNAME.EXE "

" Get-UICulture "

" Exit-PSSession "

" Get-PSSession "

" Invoke-Command -ComputerName localhost -ScriptBlock { Get-ComputerInfo } "

Remove-PSSession -Session $session

After Removing PS Session confirm check by type:
" $session "

" Get-Command | Where-Object {} | Sort-Object {} | Select-Object Name^C "

" $variable = $null
    $variable
    if($null -eq $variable)
{
"No Value is Found"
} "
##Result Output: [No Value is Found]

$variable = "test"
    if($null -eq $variable)
    {
    "No Value is Found"
    }

" if($null -eq $variable) { "No Value if Found" } else {$variable} "

##Result Output: [test]

" Write-Host "Primary Message" "
    " Write-Host "Secondary Message" " 


Comments