Skip to content

Commit 7612868

Browse files
committed
Add Start-FileShareAssessment script and documentation for comprehensive file share assessments
1 parent 42f17cb commit 7612868

4 files changed

Lines changed: 1111 additions & 0 deletions

File tree

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ scripts/
1616
│ ├── Lync/ # Lync/Skype for Business assessment tools
1717
│ ├── Microsoft365/ # Microsoft 365 assessment tools
1818
│ ├── Office365/ # Office 365 tenant assessments (legacy location)
19+
│ ├── On Premise/ # On-premise Windows Server assessments
1920
│ ├── Security/ # Security posture assessments
2021
│ └── Teams/ # Teams infrastructure assessments
2122
├── Azure/ # Azure and Microsoft 365 automation scripts
@@ -64,12 +65,20 @@ docs/ # Project documentation and guides
6465
### Microsoft Teams
6566
- `scripts/Assessment/Teams/Get-ComprehensiveTeamsReport.ps1` – Full Teams infrastructure assessment
6667

68+
### On-Premise Infrastructure
69+
- `scripts/Assessment/On Premise/Start-FileShareAssessment.ps1` – Comprehensive file share assessment with Excel reporting ([docs](docs/wiki/Assessments/OnPremise/Start-FileShareAssessment.md))
70+
- Automatic SMB share discovery
71+
- Storage analysis and NTFS permission mapping
72+
- SharePoint/OneDrive compatibility checking
73+
- Professional Excel report generation
74+
6775
## Documentation
6876

6977
### Wiki Documentation
7078
Detailed documentation for scripts is available in the `docs/wiki/` directory:
7179
- **[Lync Assessment Scripts](docs/wiki/Assessments/Lync/README.md)** - Complete Lync/Skype for Business assessment suite
7280
- **[Microsoft 365 Assessment Scripts](docs/wiki/Assessments/Microsoft365/)** - M365 tenant assessment tools
81+
- **[On-Premise Assessment Scripts](scripts/Assessment/On%20Premise/README.md)** - File share and server assessment tools
7382
- **[Office 365 Quick Start Guide](docs/Office365-Quick-Start.md)** - Getting started with O365 assessments
7483

7584
### Script Documentation
Lines changed: 350 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,350 @@
1+
# Start-FileShareAssessment.ps1
2+
3+
## Overview
4+
Comprehensive file share assessment tool that analyzes SMB shares on a Windows file server and generates a formatted Excel report. This all-in-one script automatically discovers shares, analyzes storage usage, examines NTFS permissions, identifies SharePoint/OneDrive compatibility issues, and consolidates all findings into a professional Excel workbook.
5+
6+
Designed to run directly on the file server with administrative privileges, this tool provides complete visibility into file share infrastructure for migration planning, security audits, and capacity management.
7+
8+
## Features
9+
- **Automatic Share Discovery**: Identifies all non-administrative SMB shares on the local server
10+
- **Storage Analysis**: Calculates folder sizes, file counts, and total storage consumption
11+
- **Permission Analysis**: Complete NTFS ACL inheritance mapping for all folders
12+
- **Compatibility Scanning**: Identifies files with SharePoint/OneDrive unsupported characters
13+
- **Excel Report Generation**: Creates formatted Excel workbook with auto-sizing, filtering, and frozen headers
14+
- **Performance Optimization**: Configurable parallel processing for large environments
15+
- **Detailed Logging**: Color-coded console output with error and warning tracking
16+
- **Long Path Support**: Automatic detection and enablement of long path support
17+
18+
## Prerequisites
19+
20+
### PowerShell Requirements
21+
- **PowerShell 5.1 or later** (included in Windows Server 2016+)
22+
- **Administrator privileges** on the file server
23+
- **Execution Policy**: RemoteSigned or Unrestricted
24+
25+
### Modules
26+
- **ImportExcel** - Auto-installed by script if missing
27+
28+
### System Requirements
29+
- Must be run directly on the file server (not remote execution)
30+
- Sufficient disk space for CSV exports and Excel report
31+
- Network shares must be accessible via local paths
32+
33+
## Parameters
34+
35+
### Required Parameters
36+
37+
#### -Domain
38+
The domain or organization name for the assessment. Used in report naming and identification.
39+
40+
**Type**: String
41+
**Mandatory**: Yes
42+
**Example**: `"contoso"`, `"Lawson"`
43+
44+
### Optional Parameters
45+
46+
#### -OutputDirectory
47+
Directory where CSV files and Excel report will be saved.
48+
49+
**Type**: String
50+
**Default**: Current directory (`.`)
51+
**Example**: `"C:\Reports"`, `".\FileShareAssessment"`
52+
53+
#### -ExcludeShares
54+
Array of share names to exclude from assessment. Administrative shares are excluded by default.
55+
56+
**Type**: String[]
57+
**Default**: `@("ADMIN$", "IPC$", "C$", "D$", "E$", "F$")`
58+
**Example**: `@("Backup$", "Archive$", "ADMIN$")`
59+
60+
#### -SkipPermissions
61+
Skip the permissions analysis phase. Use this for faster execution when only storage analysis is needed.
62+
63+
**Type**: Switch
64+
**Default**: False
65+
66+
#### -Workers
67+
Number of parallel workers for permission scanning. Increase for better performance on servers with many folders.
68+
69+
**Type**: Int
70+
**Default**: 50
71+
**Range**: 1-500
72+
**Example**: `100`, `200`
73+
74+
## Usage Examples
75+
76+
### Example 1: Basic Assessment
77+
```powershell
78+
.\Start-FileShareAssessment.ps1 -Domain "Contoso"
79+
```
80+
Runs complete assessment on all shares and creates `Contoso_File_Share_Assessment.xlsx` in current directory.
81+
82+
### Example 2: Custom Output Location
83+
```powershell
84+
.\Start-FileShareAssessment.ps1 -Domain "Contoso" -OutputDirectory "C:\Reports\FileShares"
85+
```
86+
Saves all output to specified directory.
87+
88+
### Example 3: Exclude Specific Shares
89+
```powershell
90+
.\Start-FileShareAssessment.ps1 -Domain "Contoso" -ExcludeShares "Backup$","Archive$","IPC$"
91+
```
92+
Excludes backup and archive shares from assessment.
93+
94+
### Example 4: Quick Storage-Only Assessment
95+
```powershell
96+
.\Start-FileShareAssessment.ps1 -Domain "Contoso" -SkipPermissions
97+
```
98+
Skips permission analysis for faster execution. Only analyzes storage and compatibility.
99+
100+
### Example 5: High-Performance Assessment
101+
```powershell
102+
.\Start-FileShareAssessment.ps1 -Domain "Contoso" -Workers 200 -OutputDirectory "D:\Assessments"
103+
```
104+
Uses 200 parallel workers for faster permission scanning on large environments.
105+
106+
### Example 6: Remote Execution via PowerShell Remoting
107+
```powershell
108+
Invoke-Command -ComputerName FileServer01 -ScriptBlock {
109+
& "C:\Scripts\Start-FileShareAssessment.ps1" -Domain "Contoso" -OutputDirectory "C:\Temp\Reports"
110+
}
111+
```
112+
Runs assessment on remote server via PowerShell remoting.
113+
114+
## Output
115+
116+
### Output File Structure
117+
```
118+
OutputDirectory/
119+
├── Contoso_File_Share_Assessment.xlsx # Main Excel report
120+
├── fileaudit_ShareName.csv # Size analysis per share
121+
├── unsupported_filenames_ShareName.csv # Compatibility issues per share
122+
└── RawData/
123+
└── permissions_ShareName_Folder.csv # Permission details per top-level folder
124+
```
125+
126+
### Output File Naming
127+
**Pattern**: `{Category}_{ShareName}_{YYYYMMDD_HHmmss}.{ext}`
128+
129+
**Examples**:
130+
- `fileaudit_Data.csv` - Storage analysis for "Data" share
131+
- `unsupported_filenames_Users.csv` - Compatibility report for "Users" share
132+
- `permissions_Projects_Engineering.csv` - Permissions for "Engineering" folder in "Projects" share
133+
134+
### Excel Workbook Structure
135+
136+
#### Share Analysis Worksheets
137+
One worksheet per share containing:
138+
- **FolderName**: Top-level folder or "Root"
139+
- **FolderSizeGB**: Size in gigabytes (rounded to 2 decimals)
140+
- **TotalFolders**: Number of subfolders
141+
- **TotalFiles**: Number of files
142+
- **Total row**: Aggregate statistics for entire share
143+
144+
#### Unsupported Characters Worksheets (USC - ShareName)
145+
One worksheet per share (if issues found) containing:
146+
- **Name**: Filename with unsupported character
147+
- **Directory**: Parent directory path
148+
- **FullName**: Complete file path
149+
150+
**Unsupported Characters**: `~ # % & * { } \ : < > ? / | "`
151+
152+
#### Permission Worksheets
153+
One worksheet per top-level folder containing:
154+
- **SharePath**: Root share path
155+
- **FolderName**: Relative folder path
156+
- **IdentityReference**: User or group (DOMAIN\User)
157+
- **FileSystemRights**: Permission level (Read, Modify, FullControl, etc.)
158+
- **AccessControlType**: Allow or Deny
159+
- **IsInherited**: True if inherited from parent
160+
161+
## Execution Workflow
162+
163+
### Phase 1: Prerequisites Check
164+
1. Validates administrator privileges
165+
2. Checks long path support (enables if needed)
166+
3. Verifies output directory exists or creates it
167+
4. Installs ImportExcel module if missing
168+
169+
### Phase 2: Share Discovery
170+
1. Enumerates all SMB shares on local server
171+
2. Filters out administrative and excluded shares
172+
3. Displays share list for verification
173+
174+
### Phase 3: Share Analysis (Per Share)
175+
1. **Storage Analysis**: Calculates size for each top-level folder
176+
2. **Permission Analysis**: Maps NTFS ACLs for all subfolders (if enabled)
177+
3. **Compatibility Scan**: Identifies files with unsupported characters
178+
179+
### Phase 4: Report Generation
180+
1. Imports all generated CSV files
181+
2. Creates Excel workbook with separate worksheets
182+
3. Applies formatting (auto-size, filters, frozen headers)
183+
4. Displays summary statistics
184+
185+
### Phase 5: Completion
186+
1. Shows execution duration and statistics
187+
2. Prompts to open Excel report
188+
3. Provides final error and warning counts
189+
190+
## Performance Considerations
191+
192+
### Small Environments (< 100 GB)
193+
- **Typical Duration**: 5-15 minutes
194+
- **Recommended Workers**: 50 (default)
195+
- **Memory Usage**: < 2 GB
196+
197+
### Medium Environments (100 GB - 1 TB)
198+
- **Typical Duration**: 15-60 minutes
199+
- **Recommended Workers**: 100-150
200+
- **Memory Usage**: 2-4 GB
201+
- **Optimization**: Consider `-SkipPermissions` for initial assessment
202+
203+
### Large Environments (> 1 TB)
204+
- **Typical Duration**: 1-4 hours
205+
- **Recommended Workers**: 150-200
206+
- **Memory Usage**: 4-8 GB
207+
- **Optimization**:
208+
- Use `-SkipPermissions` initially
209+
- Run during off-hours
210+
- Break into multiple executions per share
211+
- Increase disk I/O priority
212+
213+
### Bottlenecks
214+
- **Permission scanning** is most time-intensive
215+
- **Deep folder structures** slow enumeration
216+
- **Network shares** (UNC paths) slower than local paths
217+
- **Antivirus scanning** can impact file enumeration
218+
219+
## Common Issues & Troubleshooting
220+
221+
### Issue: "Access to path is denied"
222+
**Cause**: Insufficient permissions to access certain folders
223+
224+
**Solution**:
225+
- Run as Domain Admin or with appropriate delegated permissions
226+
- Use account with "Take Ownership" rights
227+
- Check share and NTFS permissions
228+
229+
### Issue: "Long paths are not enabled"
230+
**Cause**: Windows long path support not configured
231+
232+
**Solution**:
233+
- Script will prompt to enable automatically
234+
- Manual: `Set-ItemProperty 'HKLM:\System\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1`
235+
- Restart may be required for full effect
236+
237+
### Issue: "Failed to install ImportExcel module"
238+
**Cause**: PowerShell Gallery connectivity or permissions issue
239+
240+
**Solution**:
241+
```powershell
242+
# Manual installation
243+
Install-Module ImportExcel -Scope CurrentUser -Force -AllowClobber
244+
245+
# If behind proxy
246+
[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
247+
Install-Module ImportExcel -Scope CurrentUser -Force
248+
```
249+
250+
### Issue: Slow permission scanning
251+
**Cause**: Too many folders or insufficient workers
252+
253+
**Solution**:
254+
- Increase workers: `-Workers 200`
255+
- Skip permissions: `-SkipPermissions`
256+
- Run during off-hours
257+
- Process shares individually
258+
259+
### Issue: Excel file is locked
260+
**Cause**: Excel application has file open
261+
262+
**Solution**:
263+
- Close Excel before re-running script
264+
- Delete existing Excel file manually
265+
- Use different output directory
266+
267+
### Issue: Missing shares in output
268+
**Cause**: Share excluded by filter or inaccessible
269+
270+
**Solution**:
271+
- Check `-ExcludeShares` parameter
272+
- Verify share exists: `Get-SmbShare`
273+
- Check share permissions
274+
- Review console output for errors
275+
276+
## Security Considerations
277+
278+
### Required Permissions
279+
- **Local Administrator** on file server
280+
- **Read access** to all shares and folders
281+
- **Modify access** to output directory
282+
283+
### Data Sensitivity
284+
- **Permission exports** contain security group mappings
285+
- **Excel reports** show folder structures and file names
286+
- **Store reports securely** - they contain sensitive information
287+
- **Delete CSV files** after Excel generation if needed
288+
289+
### Best Practices
290+
- Run from secure workstation or server
291+
- Use encrypted file shares for output
292+
- Restrict access to generated reports
293+
- Delete temporary CSV files after review
294+
- Audit script execution
295+
296+
## Integration Examples
297+
298+
### Schedule as Task
299+
```powershell
300+
# Create scheduled task for monthly assessment
301+
$action = New-ScheduledTaskAction -Execute "PowerShell.exe" `
302+
-Argument "-NoProfile -ExecutionPolicy Bypass -File C:\Scripts\Start-FileShareAssessment.ps1 -Domain 'Contoso' -OutputDirectory 'D:\Reports'"
303+
304+
$trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Sunday -At 2AM
305+
306+
Register-ScheduledTask -TaskName "FileShareAssessment" -Action $action -Trigger $trigger -User "DOMAIN\ServiceAccount" -RunLevel Highest
307+
```
308+
309+
### Email Report After Completion
310+
```powershell
311+
.\Start-FileShareAssessment.ps1 -Domain "Contoso" -OutputDirectory "C:\Temp"
312+
313+
$excelFile = "C:\Temp\Contoso_File_Share_Assessment.xlsx"
314+
Send-MailMessage -To "admin@contoso.com" -From "reports@contoso.com" `
315+
-Subject "File Share Assessment - $(Get-Date -Format 'yyyy-MM-dd')" `
316+
-Body "Attached is the latest file share assessment." `
317+
-Attachments $excelFile -SmtpServer "mail.contoso.com"
318+
```
319+
320+
### Compare Reports Over Time
321+
```powershell
322+
# Generate monthly reports with timestamps
323+
$reportDate = Get-Date -Format "yyyyMM"
324+
.\Start-FileShareAssessment.ps1 -Domain "Contoso" -OutputDirectory "C:\Reports\$reportDate"
325+
326+
# Compare current vs previous month
327+
$currentReport = Import-Excel "C:\Reports\$reportDate\Contoso_File_Share_Assessment.xlsx" -WorksheetName "Data"
328+
$previousDate = (Get-Date).AddMonths(-1).ToString("yyyyMM")
329+
$previousReport = Import-Excel "C:\Reports\$previousDate\Contoso_File_Share_Assessment.xlsx" -WorksheetName "Data"
330+
331+
Compare-Object $previousReport $currentReport -Property FolderName, FolderSizeGB
332+
```
333+
334+
## Related Scripts
335+
- [Start-WindowsServerAssessment.ps1](../WindowsServer/Start-WindowsServerAssessment.md) - Complete server infrastructure assessment
336+
- [Export-ADUsersAndGroups.ps1](../ActiveDirectory/Export-ADUsersAndGroups.md) - Active Directory user and group export
337+
- [Get-MailboxPermissionsReport.ps1](../../Microsoft365/Get-MailboxPermissionsReport.md) - Office 365 mailbox permissions
338+
339+
## Version History
340+
- **v1.0** (2026-01-05): Initial release
341+
- Automatic share discovery
342+
- Storage and permission analysis
343+
- Unsupported character detection
344+
- Excel report generation with formatting
345+
346+
## See Also
347+
- [On-Premise Assessment Overview](README.md)
348+
- [File Share Migration Planning Guide](../../guides/FileShareMigration.md)
349+
- [Microsoft Docs: SMB Share Management](https://docs.microsoft.com/en-us/windows-server/storage/file-server/file-server-smb-overview)
350+
- [ImportExcel Module Documentation](https://github.com/dfinke/ImportExcel)

0 commit comments

Comments
 (0)