how to set minimum char for variable in powershell from user input code example

Example 1: how to set minimum char for variable in powershell from user input

$Server = Read-Host -Prompt 'Input your server  name'
$User = Read-Host -Prompt 'Input the user name'
$Date = Get-Date
Write-Host "You input server '$Servers' and '$User' on '$Date'"

Example 2: how to set minimum char for variable in powershell from user input

Set-Location c:\users      # Back to filesystem c: (directory users)
                              # 
   $env:userprofile           # Get value of environment variable `userprofile`
                              # -> C:\Users\user_name 
   $alias:ls                  # Get what alias 'ls' stands for
                              # -> Get-ChildItem

Example 3: how to set minimum char for variable in powershell from user input

Set-Location alias:        # To PS-Drive alias
   Get-Childitem              # All aliases

Example 4: how to set minimum char for variable in powershell from user input

Set-Location env:          # Prompt character becomes `PS Env:\>` 
                              # (environment variables)
   Get-Childitem              # Get all environment variables
                              # 
   Get-Childitem userprofile  # Get environment variable `userprofile`
                              # --> USERPROFILE C:\Users\user_name

Tags:

Misc Example