Rebuilt repo, added commands, cleadned formatting
parent
af4b30c6e9
commit
b79d3648be
@ -1 +1,10 @@
|
||||
<Place-Holder>
|
||||
# AD Commands and Scripts
|
||||
|
||||
This is a collection of Command Prompt and PowerShell commands and scripts I have collected and built for working in Windows Active Directory environment. Mostly for my own ease of access from anywhere. But I figured might as well release them into the wild.
|
||||
|
||||
There's nothing crazy in here (yet). Just some things I didn't want to commit to memory. These assume you have some know how, but not much. I've made READMEs, comments, and other notes where I felt appropriate. But please read and understand each command/script before using. And of course, feel free to tweak to your own needs.
|
||||
|
||||
### Table of Contents:
|
||||
cmd-commands.md = A document collecting Windows Command Line commands
|
||||
ps-commands.md = A document collecting Windows PowerShell commands
|
||||
ps-scripts/ = A folder containing various PowerShell scripts
|
@ -1,29 +0,0 @@
|
||||
# ADAccount Expiry PS Script v22.01.1
|
||||
|
||||
ADAccount Expiry is a PowerShell script that allows AD Admins to export into the Script's Current Directory a CSV report on Active Directory Accounts that are Expired, Expiring within 2 weeks, and/or Disabled..
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Before you begin, ensure you have met the following requirements:
|
||||
* PowerShell with the [ActiveDirectory](https://docs.microsoft.com/en-us/powershell/module/activedirectory/?view=windowsserver2022-ps) module installed (Windows only).
|
||||
* Proper permissions granted by your Admin.
|
||||
|
||||
## Installing ADAccount Expiry
|
||||
|
||||
To install ADAccount Expiry, follow these steps:
|
||||
|
||||
* Download the release Source code and place the contents into folder at a location of your choosing.
|
||||
|
||||
## Using ADAccount Expiry
|
||||
|
||||
To use ADAccount Expiry, follow these steps:
|
||||
|
||||
```
|
||||
- Run the script in PowerShell
|
||||
- The report will be exported to the current directory
|
||||
- Open the CSV in Excel
|
||||
- File > Save As . change extension dropdown to "*.xlsx" > Save
|
||||
- You may now apply any formatting/editing to the report prior to submitting it
|
||||
```
|
||||
|
||||
This project uses the following license: [Unlicense](https://unlicense.org).
|
@ -1,4 +0,0 @@
|
||||
# Roadmap
|
||||
|
||||
* Add ability to email results upon completion of script
|
||||
* Add ability to automate running of script on schedule
|
@ -1,29 +0,0 @@
|
||||
# Check Free Space PS Script v22.01.1
|
||||
|
||||
Check Free Space is a PowerShell script that allows AD Admins to check the used/max HDD space on all drives on a remote PC on the domain.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Before you begin, ensure you have met the following requirements:
|
||||
* PowerShell with the [ActiveDirectory](https://docs.microsoft.com/en-us/powershell/module/activedirectory/?view=windowsserver2022-ps) module installed (Windows only).
|
||||
* Proper permissions granted by your Admin.
|
||||
|
||||
## Installing Check Free Space
|
||||
|
||||
To install Check Free Space, follow these steps:
|
||||
|
||||
* Download the release Source code and place the contents into folder at a location of your choosing.
|
||||
|
||||
## Using Check Free Space
|
||||
|
||||
To use Check Free Space, follow these steps:
|
||||
|
||||
```
|
||||
- Open the script in a notepad program
|
||||
- Enter the hostname of the target PC in the "HOSTNAME" field, replacing the word already there
|
||||
- Save the file
|
||||
- Run the script in PowerShell
|
||||
- The results will be printed out in the terminal
|
||||
```
|
||||
|
||||
This project uses the following license: [Unlicense](https://unlicense.org).
|
@ -1,3 +0,0 @@
|
||||
# Roadmap
|
||||
|
||||
* N/A
|
@ -0,0 +1,69 @@
|
||||
### Network Reset
|
||||
|
||||
Run the following command in an elevated Command Prompt:
|
||||
|
||||
```
|
||||
ipconfig /flushdns && ipconfig /release && ipconfig /renew && ipconfig /registerdns && netsh winsock reset && shutdown /r
|
||||
```
|
||||
|
||||
This will, in order:
|
||||
1. Flush the DNS Records
|
||||
2. Release the IP Address
|
||||
3. Renew the IP Address
|
||||
4. Re-registers the DNS Records
|
||||
5. Resets the Winsock Catalog (requires a reboot after)
|
||||
6. Restarts the PC
|
||||
|
||||
Be cautious if running these commands while remotely connecting to another computer. The "&&" operator tells CMD to run the commands one after the other. If you run them one at a time instead, you will lose connection to the computer before you can complete the rest. It might be best to have someone on the other end in case you lose connection, or the computer does not regain connection after the restart.
|
||||
|
||||
<br>
|
||||
|
||||
### SFC & DISM Commands
|
||||
|
||||
The following commands will repair/replace corrupted/missing system files, as well as clear up disk space. They must all be ran in an elevated Command Prompt:
|
||||
|
||||
1.
|
||||
```
|
||||
sfc /scannow
|
||||
```
|
||||
|
||||
If it reports no issues found or all issues fixed, you are done. or, optionally skip to Step 6. Otherwise, continue to Step 2.
|
||||
|
||||
2.
|
||||
```
|
||||
DISM /Online /Cleanup-Image /CheckHealth
|
||||
```
|
||||
|
||||
3.
|
||||
```
|
||||
DISM /Online /Cleanup-Image /ScanHealth
|
||||
```
|
||||
|
||||
4.
|
||||
```
|
||||
DISM /Online /Cleanup-Image /RestoreHealth
|
||||
```
|
||||
|
||||
5. Repeat Step 1
|
||||
|
||||
Note: the following optional steps will free up disk space, but also remove files allowing uninstallation of Windows Updates
|
||||
|
||||
6.
|
||||
```
|
||||
DISM /Online /Cleanup-Image /AnalyzeComponentStore
|
||||
```
|
||||
|
||||
If prompted to reboot, do so
|
||||
|
||||
7.
|
||||
```
|
||||
DISM /Online /Cleanup-Image /StartComponentCleanup
|
||||
```
|
||||
|
||||
8.
|
||||
```
|
||||
DISM /Online /Cleanup-Image /StartComponentCleanup /ResetBase
|
||||
```
|
||||
|
||||
<br>
|
||||
|
@ -0,0 +1,43 @@
|
||||
# PS Commands
|
||||
|
||||
Note: unless otherwise stated, replace any variable such as `$ComputerName` with the appropriate data.
|
||||
|
||||
### Fetch (some) Installed Programs
|
||||
|
||||
```powershell
|
||||
Get-WmiObject win32_product -ComputerName $ComputerName | select Name, version
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### Fetch AD Groups with $SearchTerm in them
|
||||
|
||||
```powershell
|
||||
Get-ADGroup -Filter 'name -like "*$SearchTerm*"' | Sort-Object | select Name
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### Fetch Boot Time
|
||||
|
||||
```powershell
|
||||
Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName $ComputerName | slect csname, lastbootuptime
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### Fetch Computer Group Membership
|
||||
|
||||
```powershell
|
||||
Get-ADPrincipalGroupMembership (Get-ADComputer $ComputerName) | select-object name
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### Fetch User Group Membership
|
||||
|
||||
```powershell
|
||||
Get-ADPrincipalGroupMembership (Get-ADUser $Username) | select-object name
|
||||
```
|
||||
|
||||
<br>
|
@ -0,0 +1,24 @@
|
||||
# AD Account Expiry PS Script
|
||||
|
||||
ADAccount Expiry is a PowerShell script that allows AD Admins to export into the Script's Current Directory a CSV report on Active Directory Accounts that are Expired, Expiring within 2 weeks, and/or Disabled..
|
||||
|
||||
<br>
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Before you begin, ensure you have met the following requirements:
|
||||
- PowerShell with the [ActiveDirectory](https://docs.microsoft.com/en-us/powershell/module/activedirectory/?view=windowsserver2022-ps) module installed (Windows only).
|
||||
- Proper permissions granted by your Admin.
|
||||
|
||||
<br>
|
||||
|
||||
### Using ADAccount Expiry
|
||||
|
||||
To use AD Account Expiry, follow these steps:
|
||||
|
||||
1. Download the `ad-account-expiry` folder and place at a location of your choosing
|
||||
2. Run the script in PowerShell
|
||||
3. The report will be exported to the current directory
|
||||
4. Open the CSV in Excel
|
||||
5. File > Save As . change extension dropdown to "*.xlsx" > Save
|
||||
6. You may now apply any formatting/editing to the report prior to submitting it
|
@ -1,7 +1,4 @@
|
||||
# AD Account Expiration Script
|
||||
#
|
||||
# Please see the README.
|
||||
# -Tack
|
||||
|
||||
$expired = Search-ADAccount -AccountExpired | Select Name, SamAccountName, Manager, Enabled, AccountExpirationDate
|
||||
$expiring = Search-ADAccount -AccountExpiring -TimeSpan "14" | Select Name, SamAccountName, Manager, Enabled, AccountExpirationDate
|
Loading…
Reference in New Issue