# PowerShell / CMD

# Exchange Powershell CMDs

## **Step 1: Start PowerShell**

Using any of these methods, or any other you may know of:

WinKey + R (Run Dialog): powershell.exe

Start Menu -&gt; type 'Powershell', click it

Navigate to C:\\Windows\\System32\\WindowsPowerShell\\V1.0\\powershell.exe

## **Step 2: (optional/dependent) Connect to the AD Sync Server**

If you're running PowerShell on the Server where AD Connect is running, skip this step.

In the command window run the following command, replacing \[SERVERNAME\] with the name of the server you need to connect to (you may not be able to do this is PSRemoting is not enabled on the remote server):

```powershell
Enter-PSSession -ComputerName [SERVERNAME]
```

## **Step 3: Import the ADSync Module**

Run the following command:

```powershell
Import-Module ADSync
```

## **Step 4: Run the Sync Command**

Run the following Command(s):

For a Delta Sync (most common, and used for most situations):

```powershell
Start-ADSyncSyncCycle -PolicyType Delta
```

For a Full Sync (only necessary in some situations):

```powershell
Start-ADSyncSyncCycle -PolicyType Initial
```

## **Step 5: (Optional/Dependent) Exit PSSession**

If you used the Enter-PSSession command, you must exit the session or it will remain open even after terminating the PS Host. You can do so by simply using the command: Exit

# Unlock Account

unlock CMD account (codeblue)

```bash
NET USER codeblue /ACTIVE:YES
```

# CMD - Free Diskspace

Gives free diskspace, change drive letter as needed

> powershell -command "(Get-PSDrive C).Free/1GB"