title: PowerShell date: 2025-11-03 18:20:00 background: bg-[#397fe4] tags:
$PSVersionTable.PSVersion
# Output:
Major Minor Patch PreReleaseLabel BuildLabel
-- -- -- -
7 5 2
"C:\Users\maksim.zinovev\AppData\Local\Microsoft\WindowsApps\Microsoft.PowerShell_8wekyb3d8bbwe\pwsh.exe"
# verb-noun pattern
Get-Command
Get-Date
Get-Service
Get-Command -noun service
# Lists all commands with 'service' noun
Get-Help get-service # Short help
Get-Help get-service -Full # Full help
Get-Alias # List all aliases
cls # Clear host (screen)
psedit .\test.ps1 # Open file in editor
.\test.ps1 # Run script
Get-ExecutionPolicy
# => RemoteSigned (can execute code written by you or trusted author)
source/
file1.txt
file2.txt
dist/ # may or may not exist
# dist does NOT exist
Copy-Item source dist
# Result:
dist/
file1.txt
file2.txt
# dist exists
Copy-Item source dist
# Result:
dist/
source/
file1.txt
file2.txt
Copy-Item source dist/ # same as Copy-Item source dist
Copy-Item source/ dist # same as Copy-Item source dist
# On Windows, trailing slashes are ignored
Copy-Item source\* dist -Recurse
# Result: dist/ contains files from source/, not source/ itself
dist/
file1.txt
file2.txt
Summary:
source\* to copy only contents, not the folder itself.source/
file1.txt
file2.txt
dist/ # may or may not exist
# dist does NOT exist
Copy-Item source dist
# Result:
dist/
file1.txt
file2.txt
# dist exists
Copy-Item source dist
# Result:
dist/
source/
file1.txt
file2.txt
Copy-Item source dist/ # same as Copy-Item source dist
Copy-Item source/ dist # same as Copy-Item source dist
# On Windows, trailing slashes are ignored
Copy-Item source\* dist -Recurse
# Result: dist/ contains files from source/, not source/ itself
dist/
file1.txt
file2.txt
source\* to copy only contents, not the folder itself.