Get-Location
veya pwd
Set-Location [path]
veya cd [path]
cd ~
cd -
Örnek:
PS C:UsersUser> Get-Location
Path
----
C:UsersUser
PS C:UsersUser> Set-Location C:Windows
PS C:Windows>
Get-ChildItem
veya dir
veya ls
Get-ChildItem -Force
Get-ChildItem | Format-List
Örnek:
PS C:> Get-ChildItem -Force
Directory: C:
Mode LastWriteTime Length Name
---- ------------- ------ ----
d--hs- 11/14/2023 10:14 PM $Recycle.Bin
d--hsl 7/12/2023 3:51 AM Documents and Settings
d----- 7/12/2023 1:06 PM PerfLogs
d-r--- 7/12/2023 3:51 AM Program Files
d-r--- 7/12/2023 3:52 AM Program Files (x86)
d----- 7/12/2023 1:06 PM Users
d----- 11/15/2023 9:32 AM Windows
New-Item -ItemType File -Name [filename]
New-Item -ItemType Directory -Name [dirname]
New-Item -ItemType Directory -Path [path/to/dirname] -Force
Örnek:
PS C:> New-Item -ItemType File -Name newfile.txt
PS C:> New-Item -ItemType Directory -Name newdir
PS C:> New-Item -ItemType Directory -Path deeply\nested\directory -Force
Copy-Item [source] [destination]
Copy-Item [source] [destination] -Recurse
Move-Item [source] [destination]
Remove-Item [filename]
Remove-Item [dirname] -Recurse -Force
Örnek:
PS C:> Copy-Item file1.txt file2.txt
PS C:> Move-Item file2.txt newname.txt
PS C:> Remove-Item newname.txt
PS C:> Remove-Item olddir -Recurse -Force
Get-Content [filename]
Get-Content [filename] -Head 10
Get-Content [filename] -Tail 10
Örnek:
PS C:> Get-Content log.txt
PS C:> Get-Content log.txt -Tail 5
Select-String -Path [filename] -Pattern [pattern]
Get-ChildItem -Recurse | Select-String -Pattern [pattern]
Örnek:
PS C:> Select-String -Path log.txt -Pattern "error"
PS C:> Get-ChildItem -Recurse | Select-String -Pattern "TODO"
Invoke-Item [filename]
Örnek:
PS C:> Invoke-Item config.txt
Get-Process
Get-Process -Name [processname]
Örnek:
PS C:> Get-Process
PS C:> Get-Process -Name chrome
Start-Process [path/to/executable]
Stop-Process -Name [processname]
Stop-Process -Id [processID]
Örnek:
PS C:> Start-Process notepad.exe
PS C:> Stop-Process -Name notepad
Get-NetIPConfiguration
Test-NetConnection [destination]
Get-DnsClientCache
Örnek:
PS C:> Get-NetIPConfiguration
PS C:> Test-NetConnection www.google.com
Invoke-WebRequest -Uri [URL] -OutFile [filename]
Test-Connection [destination]
Örnek:
PS C:> Invoke-WebRequest -Uri "https://example.com/file.zip" -OutFile "file.zip"
PS C:> Test-Connection 8.8.8.8
Get-ComputerInfo
Get-HotFix
Get-Disk
Örnek:
PS C:> Get-ComputerInfo | Select-Object WindowsProductName, OsVersion, OsArchitecture
command1 | command2
Örnek:
PS C:> Get-Process | Where-Object {$_.CPU -gt 10} | Sort-Object CPU -Descending
Get-Alias
New-Alias -Name [alias] -Value [command]
Örnek:
PS C:> New-Alias -Name proc -Value Get-Process
$variableName = value
$variableName.GetType()
Örnek:
PS C:> $name = "John"
PS C:> $number = 42
PS C:> $name.GetType()
[int]
[double]
[string]
Örnek:
PS C:> $integer = [int]42
PS C:> $float = [double]42.5
PS C:> $text = [string]"Hello"
if (condition) { commands }
switch (variable) { ... }
Örnek:
PS C:> if ($number -gt 10) { "Greater than 10" }
PS C:> switch ($dayOfWeek) { "Monday" { "Start of the week" } "Friday" { "End of the workweek" } }
for ($i = 0; $i -lt 10; $i++) { commands }
while (condition) { commands }
Örnek:
PS C:> for ($i = 0; $i -lt 5; $i++) { Write-Output $i }
PS C:> $i = 0; while ($i -lt 5) { Write-Output $i; $i++ }
function FunctionName { ... }
FunctionName
Örnek:
PS C:> function Greet { param([string]$name) "Hello, $name!" }
PS C:> Greet -name "John"
Get-Module
Import-Module [moduleName]
Remove-Module [moduleName]
Örnek:
PS C:> Import-Module Az
PS C:> Get-Module
PS C:> Remove-Module Az
try { commands } catch { commands } finally { commands }
Örnek:
PS C:> try { $result = 1 / 0 } catch { Write-Output "Error occurred" } finally { Write-Output "Done" }
Enter-PSSession -ComputerName [remoteComputerName]
Exit-PSSession
Örnek:
PS C:> Enter-PSSession -ComputerName Server01
PS Server01> Get-Process
PS Server01> Exit-PSSession
Get-ExecutionPolicy
Set-ExecutionPolicy [policy]
Örnek:
PS C:> Get-ExecutionPolicy
PS C:> Set-ExecutionPolicy RemoteSigned
2024 © Tüm hakları saklıdır - buraxta.com