Skip to main content

PowerShell Commands

Get-Host

The Get-Host cmdlet gets an object that represents the program that is hosting Windows PowerShell.

The default display includes the Windows PowerShell version number and the current region and language settings that the host is using, but the host object contains a wealth of information, including detailed information about the version of Windows PowerShell that is currently running and the current culture and UI culture of Windows PowerShell. You can also use this cmdlet to customize features of the host program user interface, such as the text and background colors.

Out-Host

Sends output to the command line.

The Out-Host cmdlet sends output to the Windows PowerShell host for display. The host displays the output at the command line. Because Out-Host is the default, you do not have to specify it unless you want to use its parameters to change the display.

Get-Process | Out-Host -Paging

Clear-Host

The Clear-Host function removes all text from the current display, including commands and output that might have accumulated. When complete, it displays the command prompt. You can use the function name or its alias, CLS.

Clear-Host affects only the current display. It does not delete saved results or remove any items from the session. Session-specific items, such as variables and functions, are not affected by this function.

Because the behavior of the Clear-Host function is determined by the host program, Clear-Host might work differently in different host programs.

Read-Host

The Read-Host cmdlet reads a line of input from the console. You can use it to prompt a user for input. Because you can save the input as a secure string, you can use this cmdlet to prompt users for secure data, such as passwords, as well as shared data.

$pwd_secure_string = Read-Host "Enter a Password" -AsSecureString


-AsSecureString

Indicates that the cmdlet displays asterisks (*) in place of the characters that the user types as input.

Comments

Popular posts from this blog

Microsoft-Windows-User Profiles Service / Id: 1511

Windows cannot find the local profile and is logging you on with a temporary profile. Changes you make to this profile will be lost when you log off. Cause: This event can be caused by the following issues:   Your local profile is corrupt. You no longer have adequate privileges to the profile folders. User profile was deleted manually or by other means. A profile that is manually deleted does not remove the Security Identifier (SID) from the profile list in the registry. If the SID is present, Windows will try to load the profile by using the ProfileImagePath that points to a nonexistent path. Therefore, the profile cannot be loaded. Occasionally, Windows might not read your user profile correctly, for example, if your antivirus software is scanning your computer while you try to log on. Resolutions 1) Sign out and restart the computer Try restarting your computer and signing on with your user account again to resolve the issue. 2) Delete the error SID and ...

Apply Azure monitoring metrics using PowerShell

Azure Monitor - Apply Azure monitoring metrics using PowerShell  #Creating an action group as an object $action = [Microsoft.Azure.Management.Monitor.Management.Models.ActivityLogAlertActionGroup]::New("/subscriptions/SubscriptionIDUpdatehere/resourceGroups/alert/providers/Microsoft.Insights/actiongroups/alertaction") #Setting up condition as an object $condition1 = New-AzMetricAlertRuleV2Criteria `  -MetricName "Percentage CPU" `  -MetricNameSpace "Microsoft.Compute/virtualMachines" `  -TimeAggregation Average `  -Operator GreaterThan `  -Threshold 96 $condition2 = New-AzMetricAlertRuleV2Criteria `  -MetricName "Available Memory Bytes" `  -MetricNameSpace "Microsoft.Compute/virtualMachines" `  -TimeAggregation Average `  -Operator LessThan `  -Threshold 1000000000 $condition3 = New-AzMetricAlertRuleV2Criteria `  -MetricName "Data Disk IOPS Consumed Percentage" `  -MetricNameSpace "Microsoft.Compute/virtualMachines" ...

Useful Open Manage Server Administrator(omreport) commands for Dell server

The Open Manage command line interface allows you to check the state of your hardware and do hardware settings. Below commands are quick reference for Dell server, you can always use "omhelp omreport" commands to show help manual of "omreport". 1. System component properties. System logs omreport system alertlog  --View alert log. omreport system esmlog    --View hardware (Embedded System Management) log. omreport system cmdlog    --View command log. OS omreport system operatingsystem Summary of all system components(Including major components versions) omreport system summary Version report for all updateable components. (Including BIOS,OS and controller versions) omreport system version 2. Chassis component properties. Power (Check power peak stats and threshold) omreport chassis pwrmonitoring Check power capacity omreport chassis pwrmanagement Power health status omreport chassi...