Keywords: PsExec | admin$_share | remote_access_troubleshooting
Abstract: This article provides an in-depth exploration of the "network name cannot be found" error encountered when using PsExec for remote installation or execution, focusing on the root cause of disabled default admin$ shares. Two solutions are presented: manually creating the admin$ share and enabling AutoShareServer via registry to automatically create administrative shares. Through detailed step-by-step instructions and code examples, readers gain understanding of Windows network sharing mechanisms and effective troubleshooting methods for remote access failures.
When using the PsExec tool for remote operations, users may encounter the following error message:
Couldn't access ServerName
The network name cannot be found
Make sure that the default admin$ share is enable on ServerName
This error typically indicates that the default administrative share admin$ is not properly enabled on the target server, causing remote access to fail. The admin$ share is a special Windows system share used for remote administration, defaulting to the C:\Windows directory.
Root Cause Analysis
Windows operating systems create a series of administrative shares by default (such as admin$, C$, D$, etc.). These shares end with a dollar sign ($) and are invisible during normal network browsing. The admin$ share is particularly important as it provides remote management tools (like PsExec) with access to critical system directories. When these shares are disabled or improperly configured, dependent remote operations will fail.
Solution 1: Manually Create the admin$ Share
The most direct solution is to manually create the admin$ share. Here are the detailed steps:
- Navigate to the
C:\windowsdirectory, right-click and selectProperties - Click the
Advanced Sharingbutton - Check the
Share this foldercheckbox - Enter
admin$in the share name field, then clickPermissions - It is recommended to remove the
Everyonegroup and add only specific users required for PsExec command execution
After completing these steps, rerun the PsExec command, and the issue should typically be resolved.
Solution 2: Enable Automatic Sharing via Registry
For scenarios requiring management of multiple servers, enabling automatic sharing through the registry is more efficient. Windows provides the AutoShareServer registry entry to control automatic creation of administrative shares.
Here are the enabling steps:
- Open Registry Editor (run
regedit) - Navigate to:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters - Find or create a DWORD value named
AutoShareServer - Set its value to
1(enable automatic sharing)
After configuration, restart the Server service or reboot the computer for changes to take effect. The system will automatically create all administrative shares, including admin$.
Security Considerations
When enabling the admin$ share, security factors must be considered:
- Principle of least privilege: Grant access only to necessary users, avoid using the Everyone group
- Network isolation: Ensure administrative shares are available only in trusted network environments
- Monitoring and auditing: Regularly check share access logs to detect anomalous activities
- Alternative considerations: For highly secure environments, consider using more secure remote management protocols
In-depth Technical Principles
Windows administrative sharing mechanism is implemented based on the Server Message Block (SMB) protocol. When PsExec attempts to connect to a remote server, it first tries to access the admin$ share to verify permissions and establish an administrative session. If this share doesn't exist or access is denied, the "network name cannot be found" error occurs.
From a system architecture perspective, the enabled status of admin$ share is influenced by multiple factors:
- Windows service configuration: The Server service must be running normally
- Firewall settings: Must allow communication on SMB-related ports (typically 445)
- Group policy restrictions: Some organizational policies may disable administrative shares
- System version differences: Different Windows versions may handle administrative shares differently
Practical Code Examples
The following PowerShell script demonstrates how to programmatically check and enable the admin$ share:
# Check admin$ share status
$share = Get-SmbShare -Name "admin$" -ErrorAction SilentlyContinue
if (-not $share) {
Write-Host "admin$ share not found, creating..."
# Create admin$ share
New-SmbShare -Name "admin$" -Path "C:\Windows" -FullAccess "Administrators"
# Verify share creation
$newShare = Get-SmbShare -Name "admin$"
if ($newShare) {
Write-Host "admin$ share created successfully"
}
} else {
Write-Host "admin$ share already exists"
}
Extended Troubleshooting
If the above methods still don't resolve the issue, the following aspects may need checking:
- Network connectivity: Ensure proper network connection between client and server
- Authentication issues: Confirm that credentials used have sufficient permissions
- Service status: Check if the Server service is running normally
- Firewall configuration: Verify that SMB ports are open
- Security software interference: Some security software may block administrative share access
By systematically applying these solutions and troubleshooting steps, most PsExec remote access issues can be effectively resolved. Understanding how Windows sharing mechanisms work is crucial for preventing similar problems and conducting efficient system management.