Full PowerShell script (Run as Administrator):
# Set the NFS share variables:
$NFSServer = "\\server\mnt\raid\NFS"
$DriveLetter = "Z:"
# Enable NFS Client feature
Enable-WindowsOptionalFeature -FeatureName ServicesForNFS-ClientOnly, ClientForNFS-Infrastructure -Online -NoRestart -ErrorAction SilentlyContinue
# Mount anonymously
mount -o anon $NFSServer $DriveLetter
# Get mount info and parse UID/GID
$mountOutput = mount
$mountInfo = $mountOutput | Where-Object { $_ -match $DriveLetter.TrimEnd(':') }
if ($mountInfo) {
# Parse UID from mount output (format: UID=xxxx)
if ($mountInfo -match 'UID[=:]?\s*(-?\d+)') {
$UID = [int]$Matches[1]
}
# Parse GID from mount output (format: GID=xxxx)
if ($mountInfo -match 'GID[=:]?\s*(-?\d+)') {
$GID = [int]$Matches[1]
}
Write-Host "Found UID: $UID, GID: $GID"
# Set registry values
$regPath = "HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default"
# Create path if it doesn't exist
if (-not (Test-Path $regPath)) {
New-Item -Path $regPath -Force | Out-Null
}
Set-ItemProperty -Path $regPath -Name "AnonymousUid" -Value $UID -Type DWord
Set-ItemProperty -Path $regPath -Name "AnonymousGid" -Value $GID -Type DWord
Write-Host "Registry values set successfully"
# Restart NFS client services
Write-Host "Restarting NFS client services..."
Stop-Service nfsclnt -Force -ErrorAction SilentlyContinue
Stop-Service nfsrdr -Force -ErrorAction SilentlyContinue
Start-Service nfsrdr
Start-Service nfsclnt
Write-Host "Done! NFS client configured with UID=$UID and GID=$GID"
}
else {
Write-Warning "Could not find mount information for $DriveLetter"
Write-Host "Mount output was:"
$mountOutput
}
PowerShell:
Enable-WindowsOptionalFeature -FeatureName ServicesForNFS-ClientOnly, ClientForNFS-Infrastructure -Online -NoRestart
Or enable NFS client using: Control Panel > Turn Windows features on or off > Services for NFS (complete)
mount -o anon \\server\mnt\raid\NFS Z:
Find UID and GID to enable write permissions:
mount
Create DWORD (32-bit) and set UID and GID as value:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default AnonymousUid AnonymousGid
Restart NFS client without having to restart Windows.
net stop nfsclnt net stop nfsrdr net start nfsrdr net start nfsclnt