To | Do This |
---|---|
Produce a listing of all variables defined in a Windows PowerShell session | Use the Set-Location cmdlet to change location to the variable PSDrive, then use the Get-ChildItem cmdlet |
Obtain a listing of all the aliases | Use the Set-Location cmdlet to change location to the alias PSDrive, then use the Get-ChildItem cmdlet to produce a listing of aliases. Pipeline the resulting object into the Where-Object cmdlet and filter on the name property for the appropriate value |
Delete a directory that is empty | Use the Remove-Item cmdlet and supply the name of the directory |
Delete a directory that contains other items | Use the Remove-Item cmdlet and supply the name of the directory and specify the recurse argument |
Create a new text file | Use the New-Item cmdlet and specify the -path argument for the directory location. Supply the name argument, and specify the type argument as file. Example: new-item -path C:\Mytest -name Myfile.txt-type file |
Obtain a listing of registry keys from a registry hive | Use the Get-ChildItem cmdlet and specify the appropriate PSDrive name for the -path argument. Complete the path with the appropriate registry path. Example: gci -path HKLM:\software |
Obtain a listing of all functions on the system | Use the Get-ChildItem cmdlet and supply the PSDrive name of function:\ to the path argument. Example: gci -path function:\ |