{"id":21861261,"url":"https://github.com/caglaryalcin/shell-commands","last_synced_at":"2026-04-18T02:31:20.509Z","repository":{"id":116964561,"uuid":"542632028","full_name":"caglaryalcin/shell-commands","owner":"caglaryalcin","description":"Powershell commands I use often","archived":false,"fork":false,"pushed_at":"2023-09-20T12:17:29.000Z","size":110,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-21T20:18:27.916Z","etag":null,"topics":["command","commands","powershell","shell"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/caglaryalcin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-28T14:25:50.000Z","updated_at":"2025-02-24T21:47:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"ab96660f-bbac-4bdd-ab35-b699e561d242","html_url":"https://github.com/caglaryalcin/shell-commands","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/caglaryalcin/shell-commands","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caglaryalcin%2Fshell-commands","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caglaryalcin%2Fshell-commands/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caglaryalcin%2Fshell-commands/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caglaryalcin%2Fshell-commands/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/caglaryalcin","download_url":"https://codeload.github.com/caglaryalcin/shell-commands/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caglaryalcin%2Fshell-commands/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31953760,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command","commands","powershell","shell"],"created_at":"2024-11-28T03:10:56.136Z","updated_at":"2026-04-18T02:31:20.488Z","avatar_url":"https://github.com/caglaryalcin.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"## shell-commands\n\nPS commands I use often\n\n#### Remote PS\n```powershell\nEnter-PSSession -ComputerName nameishere\n```\n\n#### Remote cmd\n```powershell\npsexec \\\\hostname cmd\n```\n\n#### Delete files with cmd\n```powershell\nrmdir /s /q C:\\Windows.old\n```\n```powershell\ntakeown /F \"C:\\Windows.old\" /A /R /D Y\n```\n```powershell\nRD /S /Q \"C:\\Windows.old\"\n```\n\n#### .net 3.5 setup (Source:Windows iso)\n```powershell\nDISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:X:\\sources\\sxs\n```\n\n#### Check .net version\n```powershell\nGet-ItemProperty 'HKLM:\\SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full' | Select-Object Version\n```\n\n#### Get hyper-v host\n```powershell\nGet-ItemProperty 'HKLM:\\SOFTWARE\\Microsoft\\Virtual Machine\\Guest\\Parameters\\' | Select-Object HostName\n```\n\n#### Check hash\n```powershell\nGet-FileHash .\\dosya -Algorithm SHA256\n```\n\n#### Get permissions\n```powershell\nnet localgroup Administrators\n```\n```powershell\nnet localgroup \"Remote Desktop Users\"\n```\n\n#### Get users with ID (local)\n```powershell\ngwmi win32_userprofile | select localpath, sid\n```\n\n#### Get user from group\n```powershell\nGet-ADGroupMember -Identity \"groupname\" -Recursive | Get-ADUser -Properties Name,  EmployeeID, userPrincipalName, distinguishedName\n```\n\n#### Get user from group with export\n```powershell\nGet-ADGroupMember -Identity \"groupname\" -Recursive | Get-ADUser -Properties Name, EmployeeID, userPrincipalName, distinguishedName | Export-csv -path C:\\caglar-export\\test.csv -notypeinformation -Encoding UTF8 \n```\n\n#### List dc\n```powershell\nGet-ADDomainController -Filter * | Select hostname, site\n```\n\n#### Install Telnet Client\n```powershell\nInstall-WindowsFeature -name Telnet-Client\n```\n\n#### Get locked user from domain\n```powershell\nSearch-ADAccount -LockedOut -ResultPageSize 2000 -resultSetSize $null | Select-Object Name, SamAccountName, DistinguishedName | Export-CSV “C:\\LockedUserList.CSV” -NoTypeInform\n```\n\n#### Get Group Member from AD\n```powershell\nGet-ADGroupMember -Identity 'Groupname' -Recursive | Select Name\n```\n\n#### Get Active Users on AD\n```powershell\nGet-ADUser -server dc.hostname.com -Filter {enabled -eq \"true\" -and objectclass -eq \"user\"} -properties * | Select-Object Name,SamAccountName,lastlogondate | \nExport-csv C:\\DomainUsers.csv -NoTypeInformation -Encoding UTF8\n```\n\n#### Get domain users\n```powershell\nGet-ADUser -server adserver.domain.com -Filter {enabled -eq \"true\" -and objectclass -eq \"user\"} -properties lastlogondate, enabled | Select-Object Name,SamAccountName,lastlogondate, enabled | \nExport-csv C:\\domain_users.csv -NoTypeInformation -Encoding UTF8\n```\n---------------------\n\n```powershell\n$attributes = 'EmployeeID','Name','SamAccountName','Description','PasswordLastSet','emailaddress','PasswordNeverExpires','whencreated','whenchanged','lastlogondate',@{n='lastlogontimeStamp';e={[DateTime]::FromFileTime($_.lastlogontimestamp)}},'enabled'\n \nGet-ADUser -server adserver.domain.com -Filter {enabled -eq \"true\" -and objectclass -eq \"user\"} -properties * | select $attributes | \nExport-csv C:\\domain_users.csv -NoTypeInformation -Encoding UTF8 -Delimiter \";\" \n```\n\n#### Get mail address from AD users\n```powershell\nGet-ADObject -Filter {(objectclass -eq 'contact') -and ((targetaddress -like \"*domain.com*\") -or (targetaddress -like \"*filteradresshere*\"))} -Properties *  | \nselect cn,targetaddress,memberof,objectclass | out-file c:\\therearefilter_contacts.csv \n```\n\n#### Get name and mail address from AD groups\n```powershell\nGet-ADGroup -properties * -Filter  {(name -like \"*sube grubu*\")} |select name,mail | Export-Csv \"C:\\SubeGrubu.csv\" -Encoding UTF8 -NoTypeInformation\n```\n\n#### Get last modified date of computer object from AD\n```powershell\nGet-ADcomputer -Filter 'Name -like \"*computernamewashere\"' -properties * | sort lastlogondate | FT name, whenChanged\n```\n\n#### Get OU of hostname from AD\n```powershell\nGet-ADcomputer -Filter 'Name -like \"*computernamewashere\"' -properties * | sort lastlogondate | FT name, CanonicalName\n```\n\n#### Get OU of hostname list from AD\n```powershell\nGet-Content C:\\hostnames.txt | foreach {Get-ADComputer -Filter {Name -Like $_} -properties *} | sort lastlogondate | FT name, CanonicalName\n```\n\n#### Change dns of servers\n```powershell\n$servers = Get-Content \"E:\\liste.txt\"\n#$servers = \"hostname\"\nforeach($server in $servers){\n    Write-Host \"Connect to $server...\"\n    $nics = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $server   | Where{$_.IPEnabled -eq \"TRUE\"}\n    $newDNS = \"1.1.1.1\",\"1.0.0.1\"\nforeach($nic in $nics){\n    Write-Host \"`tExisting DNS Servers \" $nic.DNSServerSearchOrder\n    $x = $nic.SetDNSServerSearchOrder($newDNS)\n    if($x.ReturnValue -eq 0){\n    Write-Host \"`tSuccessfully Changed DNS Servers on \" $server -ForegroundColor Green\n     }\n     else{\n     Write-Host \"`tFailed to Change DNS Servers on \" $server -ForegroundColor Red\n         }\n   }\n}\n```\n\n#### Check disk size\n```powershell\nGet-Volume -DriveLetter C\n```\n\n#### Set TR Timezone\n```powershell\nSet-TimeZone -Id \"Turkey Standard Time\"\n```\n\n#### Applications sent from SCCM\n```powershell\nget-wmiobject -query \"SELECT * FROM CCM_Application\" -namespace \"ROOT\\ccm\\ClientSDK\" | Select-Object FullName, InstallState\n```\n\n#### Get installed softwares\n```powershell\nget-wmiobject -Class Win32_Product | Select-Object Name, Version\n```\n\n#### Get services status\n```powershell\nGet-Service -Name \"servicesname*\"\n```\n```powershell\nGet-Service | Where-Object {$_.Status -eq \"Running\"}\n```\n```powershell\nGet-Service \"s*\" | Sort-Object status\n```\n\n#### To get information about the last time the servers communicated with the domain\n```powershell\n$ComputerList = get-content \"E:\\Liste.txt\"\n#$ComputerList = \"hostname\"\n  foreach ($Computer in $ComputerList)\n{\n  TRY\n    {\n  $LastLogonQuery = Get-ADComputer $Computer -Properties lastlogontimestamp | \n    #Select-Object @{n=\"Computer\";e={$_.Name}}, @{Name=\"Lastlogon\"; Expression={[DateTime]::FromFileTime($_.lastLogonTimestamp)}}\n    Select-Object @{n='lastLogonTimestamp';e={[DateTime]::FromFileTime($_.lastLogonTimestamp).ToString(\"dd/MM/yyyy\")}}\n     $Computer   +  \"*ADLastLogonTime*\"  + $LastLogonQuery.lastLogonTimestamp\n }\nCatch    {\n   $Computer   +  \"*ADLastLogonTime*\"  + \"NOObject\"\n\t}\n}\n```\n\n#### Install sscm agent\n```powershell\nCCMSetup.exe /mp:sub.domain.com SMSSITECODE=domainsitecode FSP=sscmserver.domain.com\n```\n\n#### Collectively Move all on AD OU\n```powershell\nGet-Content C:\\import.txt| foreach {Get-ADComputer -Filter {Name -Like $_} |Move-ADObject -TargetPath \"OU=Tier0,OU=App Servers,OU=OU,OU=OU,DC=DC,DC=local\"}\n```\n\n#### Get samaccountname from name and surname\n```powershell\nGet-ADUser -Filter 'Name -like \"*namesurname\"' | Format-Table Name,SamAccountName -A\n```\n\n#### Get userPrincipalNames from samaccountname\n```powershell\nGet-ADUser accountname -Properties * | select userPrincipalName\n```\n\n#### Exchange Mail Inbox Receipt Check\n```powershell\nGet-TransportService | Get-MessageTrackingLog -start \"9/22/2022 9:00:00 AM\" -end \"9/22/2022 3:00:00 PM\" -Sender \"sender@mail.com\" -Recipients \"recipients@mail.com\"\n```\n\n#### Set Mail AutoReply\n```powershell\nSet-MailboxAutoReplyConfiguration ADUSERNAME -AutoReplyState enabled -ExternalAudience all -InternalMessage \"Message was here\"\n```\n\n#### Get user mail export\n```powershell\n(all)\nNew-MailboxExportRequest -Mailbox username -AcceptLargeDataLoss -BadItemLimit 150 -FilePath \\\\filepath\\file.pst\n(The date is intermittent / The dates should be set according to the zone setting of the machine to be exported)\nNew-MailboxExportRequest -ContentFilter {(Received -lt '07/26/2021') -and (Received -gt '07/05/2021')} -Mailbox \"ADusername\" -Name nameishere -FilePath \\\\filepath\\inboxname.pst\n(status export)\nGet-MailboxExportRequest\n(remove of completed)\nGet-MailboxExportRequest -Status completed | Remove-MailboxExportRequest\n```\n\n#### Get mail groups from AD (run with exc management shell)\n```powershell\nGet-DistributionGroup -Filter * -ResultSize unlimited |select name, PrimarySmtpAddress  | Export-Csv c:\\MailGroup.csv -NoTypeInformation -Encoding UTF8\n```\n\n#### Get 0kb files from path\n```powershell\nNew-PSDrive -Name P -PSProvider FileSystem -Root \"\\\\server\\share\"\n```\n\n```powershell\nGet-ChildItem -Path P:\\SourcePATH -Recurse -Force | Where-Object { $_.PSIsContainer -eq $false -and $_.Length -eq 0 } | Select -ExpandProperty FullName | Add-Content -Path c:\\export.txt\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaglaryalcin%2Fshell-commands","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaglaryalcin%2Fshell-commands","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaglaryalcin%2Fshell-commands/lists"}