Quick PowerShell script to create network shares for legacy scanners. Saves you from clicking through Windows sharing dialogs and firewall settings.
Got an old scanner that needs to save files to a network folder? This script handles the Windows setup automatically - firewall rules, user accounts, folder permissions, the works. Takes 30 seconds instead of 10 minutes of clicking around.
- Creates a
Scan
folder on your desktop - Sets up SMB sharing with proper permissions
- Creates a
scan
user (password:scan
) for scanner login - Configures Windows firewall to allow file sharing
- Sets network profile to Private (required for sharing)
- Optional detailed logging to
scanner-setup.log
(enabled by default) - Optional tracking of shared paths in
list.txt
(disabled by default)
- Download and run the script (will ask for admin rights)
- Point your scanner to
\\YOUR-PC-NAME\scan
- Use username
scan
and passwordscan
That's it. Your scanner can now save files to the desktop Scan folder.
Default behavior (no logging, no list.txt):
.\Setup-ShareFolder-Scanner.ps1
Enable logging and create list.txt:
.\Setup-ShareFolder-Scanner.ps1 -EnableLog -CreateListFile
Clean operation (minimal files):
.\Setup-ShareFolder-Scanner.ps1
Custom credentials:
.\Setup-ShareFolder-Scanner.ps1 -Username "scanner" -Password (Read-Host -AsSecureString)
Configuration file setup:
.\Setup-ShareFolder-Scanner.ps1 -ConfigFile "config.json"
Test connection after setup:
.\Setup-ShareFolder-Scanner.ps1 -TestConnection
Remove scanner share and user:
.\Setup-ShareFolder-Scanner.ps1 -Cleanup
Get help:
Get-Help .\Setup-ShareFolder-Scanner.ps1 -Full
- Auto-elevation: Automatically requests administrator privileges
- Smart defaults: No logging, no list.txt by default for clean operation
- Configuration files: JSON configuration support for enterprise deployments
- Custom credentials: Support for custom username/password combinations
- Connection testing: Built-in share connectivity validation with
-TestConnection
- Cleanup mode: Easy removal of scanner components with
-Cleanup
- Comprehensive logging: Optional detailed logs in
scanner-setup.log
- Error handling: Automatic rollback on failures with resource tracking
- Configuration validation: Verifies everything works after setup
- Share conflict resolution: Handles existing share name conflicts
- Legacy compatibility: SMB settings optimized for old scanners
- Download the
Setup-ShareFolder-Scanner.ps1
file - Right-click and "Run with PowerShell" (or run from command line)
- Click "Yes" when Windows asks for admin privileges
Create a JSON configuration file for enterprise deployments:
{
"Username": "scanner",
"FolderName": "ScannerShare",
"FolderPath": "C:\\SharedScan",
"EnableLog": true
}
Use with: .\Setup-ShareFolder-Scanner.ps1 -ConfigFile "config.json"
Configuration options:
Username
: Custom scanner user account nameFolderName
: Custom share and folder nameFolderPath
: Custom path for the shared folderEnableLog
: Enable detailed logging (true/false)
- Scanner folder:
%USERPROFILE%\Desktop\Scan
(scan destination) - Log file:
scanner-setup.log
(optional detailed operation log, disabled by default) - List file:
list.txt
(optional share tracking with-CreateListFile
, disabled by default) - Config file: Custom JSON configuration files (when using
-ConfigFile
)
Works with most office scanners and multifunction printers that support SMB/CIFS, including older Canon, HP, Xerox, and Ricoh models.
Uses simple credentials (scan
/scan
) because that's what most legacy scanners expect. The shared folder only allows access from your local network. Change the password in the script if needed.
Scanner can't connect?
- Check that both devices are on the same network
- Try using the computer's IP address instead of name:
\\192.168.1.100\Scan
- Verify the scanner supports SMB v1/v2 protocol
- Make sure Windows firewall isn't blocking connections
- Test from another device:
\\COMPUTER-NAME\Scan
"Access Denied" errors?
- Ensure you're using the correct credentials:
scan
/scan
- Try connecting from Windows Explorer first to test
- Check if the share exists:
Get-SmbShare -Name Scan
- Verify user permissions:
Get-SmbShareAccess -Name Scan
Script won't run?
- Right-click the file and check "Unblock" if downloaded from internet
- Make sure you're running PowerShell as administrator
- Check PowerShell execution policy:
Get-ExecutionPolicy
- Try:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Canon Printers: Use SMB v1, try IP address format HP MFPs: Usually work with default settings, may need SMB v2 Xerox/Ricoh: Often require exact computer name, not IP Brother: May need manual port 445 verification
# Test if SMB service is running
Get-Service -Name LanmanServer
# Check if port 445 is open
Test-NetConnection -ComputerName localhost -Port 445
# List all shares
Get-SmbShare
# Test share access
net use * \\localhost\Scan /user:scan scan
- Windows 7 or later
- PowerShell (comes with Windows)
- Local network connection
Made this because setting up scanner shares manually is tedious. Hope it saves you some time.