Last active
July 20, 2023 21:13
-
-
Save DorukUlucay/f8be8ab0e4ba238b4cebe094f8747b55 to your computer and use it in GitHub Desktop.
Powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for($i=1; $i -le 5; $i++) { mkdir "TEMP$i" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I don't know what happens if there are more than 1 processes. find out. | |
# get a process that has w3 in it's name | |
Get-Process *w3* | |
# or | |
ps *w3* | |
# get a process that has w3 in in's name and kill it | |
Get-Process *w3* | kill | |
# or | |
ps *w3* | kill |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module Webadministration | |
Get-ChildItem -Path IIS:\Sites | select Name,PhysicalPath | ConvertTo-Json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$url = "https://api.ipify.org?format=json" | |
$interval = 10 | |
while (1) { | |
Start-Sleep -seconds $interval | |
Clear-Host | |
Write-Output "curled $($url) at $(get-date) `n" | |
Invoke-WebRequest $url | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ls -filter "*irew*" | |
#ls'içinde irew geçenleri filtreler |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# prepend D_ to every file in a dir | |
ls | % { mv $_.Name "D_$_"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-ChildItem $tdc -Recurse -Force -Directory | Sort-Object -Property FullName -Descending | Where-Object { $($_ | Get-ChildItem -Force | Select-Object -First 1).Count -eq 0 } | Remove-Item -Verbose |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-ChildItem .\ -include bin,obj -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# içinde -- geçen dosya adlarındaki -'lerden birini siler | |
Get-ChildItem zula-pc* | ForEach-Object { | |
$newname = $_.Name.Replace("--", "-"); | |
Write-Output $_; | |
Move-Item $_ $newname; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get a list of files in a folder and it's subfolders(recursive) | |
# params | |
$mainpath = "C:\S\folderwithmdfiles" # target dir | |
$filter = @("*.md") # file types | |
$outputFile = "C:\temp\output.txt" # output file path | |
$files = @() | |
function generate { | |
param ( | |
$currentpath | |
) | |
$filesindir = get-childitem $currentpath\* -Include $filter | |
foreach ($i in $filesindir) { | |
$global:files += ,@("$($currentpath)\$($i.Name)") | |
} | |
$subdirs = Get-ChildItem $currentpath -directory | |
foreach ($item in $subdirs) { | |
generate("$($currentpath)\$($item)") | |
} | |
} | |
generate $mainpath | |
foreach ($item in $files) { | |
Add-Content $outputFile $item | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$curl_one_site = { | |
param($site) | |
Write-Output "curled $($site) at $(get-date)" | |
Invoke-WebRequest $site | |
} | |
ForEach ($line in (Get-Content "warmup.txt")) { | |
Start-Job -ScriptBlock $curl_one_site -ArgumentList $line | |
} | |
#inside warmup txt | |
<# | |
somesite.com | |
anothersite.com | |
awebsite.com | |
#> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment