Skip to content

Instantly share code, notes, and snippets.

@DorukUlucay
Last active July 20, 2023 21:13
Show Gist options
  • Save DorukUlucay/f8be8ab0e4ba238b4cebe094f8747b55 to your computer and use it in GitHub Desktop.
Save DorukUlucay/f8be8ab0e4ba238b4cebe094f8747b55 to your computer and use it in GitHub Desktop.
Powershell
for($i=1; $i -le 5; $i++) { mkdir "TEMP$i" }
# 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
Import-Module Webadministration
Get-ChildItem -Path IIS:\Sites | select Name,PhysicalPath | ConvertTo-Json
$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
};
ls -filter "*irew*"
#ls'içinde irew geçenleri filtreler
# prepend D_ to every file in a dir
ls | % { mv $_.Name "D_$_"}
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
Get-ChildItem .\ -include bin,obj -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }
# içinde -- geçen dosya adlarındaki -'lerden birini siler
Get-ChildItem zula-pc* | ForEach-Object {
$newname = $_.Name.Replace("--", "-");
Write-Output $_;
Move-Item $_ $newname;
}
# 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
}
$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