Powershell on the command line

1. how it is used on the command line

2. how it is used for programming and scripting work

3. (likely) how it is used in the cloud like azure

These notes are for command line


# file array
$x = dir 

# first entry
$x1 = $x[0]

# find its type
$x1 | Get-type

# find the methods
$x1 | Get-Member

# Get all file (objects) recursively
dir *.sql -Recurse

# Select that have changed since
dir *.sql -Recurse | where -Property CreationTime -gt '9/1/2020'

#note the time format is locale sensitive

This link on commandlets in powershell could be useful

1. Use "exit" at the command line to quit

2. To start a powershell use the windows search icon to look for "powershell"



#The following will give you the attributes
get-alias | get-member

#Then you can chose the objects 
#whose attribute matches to what you like
get-alias | Where-Object -Property ReferencedCommand -Like "*var*"

Get-Variables - Global variables such as version number etc.
Get-Module - Show modules
Get-Command - Show commandlets in a module
Get-Help
Get-Help -examples
Get-Member - Show me the attributes of an object
Select-Object First
Get-alias - Show aliases
Get-PSProviders - show drives
Get-ComputerInfo

You have things like

min

max

average

etc....


Lists registered public repos
PS C:\satya\data\code\power-shell> Get-PSRepository

Name        InstallationPolicy   SourceLocation
----        ------------------   --------------
PSGallery   Untrusted            https://www.powershellgallery.com/api/v2

Module for MS Teams

Create a new chat with MS Teams Powershell module

Search for: Create a new chat with MS Teams Powershell module

MS Docs: Powershell for MS Teams

Hello 2025

  1. dir - do a wild card search on directory trees
  2. select - Select a set of columns from the output of the dir or any command
  3. sort - sort by any column from the previous output (via pipe)
  4. ....
  5. help - use help to ask about each of the commands above

dir *somefile* | select LastwriteTime, FullName | sort LastWriteTime -descending
  1. dir Env: #List environment
  2. ls Env:
  3. gci Env:
  4. ... they all same
  5. ...
  6. $env:path #value of path variable

# List environment variables whose name is related 
# to python virtual environments

dir Env: | where name -Like *virtual*
  1. Ex: del .git -Recurse -Force
  2. The -force will remove read only or hidden directories as well
  3. .git is an example

dir *.pptx -Recurse | Select-Object Directory, name