tuk*_*kan 7 windows-registry windows-7 powershell network-shares roaming-profiles
这确实是一个烦人的错误 -尝试对“文件系统”提供程序执行 InitializeDefaultDrives 操作失败。,每次我在公司网络之外启动 powershell 时都会得到它。
我在域中有一个笔记本。我有两种使用它的方法。首先是公司网络内部,一切正常。第二种方式是当我在办公室外面时,通过 VPN 连接。每次启动 powershell 时都会产生上述错误。
根据我对错误的重新搜索,原因似乎是无法连接的驱动器或资源。
我试图找出可能的原因。由于主文件夹结构发生了一些变化,我对此表示怀疑。
我已经在两个位置执行了这个脚本:
Write-Verbose -Message 'Get-PSDrive -PSProvider FileSystem' -verbose
echo 'Get-PSDrive -PSProvider FileSystem' | Out-File -Append -Encoding "UTF8" -FilePath filesystem.log
Get-PSDrive -PSProvider FileSystem | Out-File -Append -Encoding "UTF8" -FilePath filesystem.log
Write-Verbose -Message 'net use' -verbose
echo 'net use' | Out-File -Append -Encoding "UTF8" -FilePath filesystem.log
net use | Out-File -Append -Encoding "UTF8" -FilePath filesystem.log
Write-Verbose -Message '[System.IO.DriveInfo]::GetDrives() | Format-Table' -verbose
echo '[System.IO.DriveInfo]::GetDrives() | Format-Table' | Out-File -Append -Encoding "UTF8" -FilePath filesystem.log
[System.IO.DriveInfo]::GetDrives() | Format-Table | Out-File -Append -Encoding "UTF8" -FilePath filesystem.log
# does not work properly
# Write-Verbose -Message 'Get-CimInstance -ClassName Win32_LogicalDisk -ComputerName $env:COMPUTERNAME' -verbose | Out-File -Append -Encoding "UTF8" -FilePath filesystem.log
#Get-CimInstance -Class Win32_LogicalDisk | Out-File -Append -Encoding "UTF8" -FilePath filesystem.log
Write-Verbose -Message 'Get-CimInstance -Class Win32_NetworkConnection' -verbose
echo 'Get-CimInstance -Class Win32_NetworkConnection' | Out-File -Append -Encoding "UTF8" -FilePath filesystem.log
Get-CimInstance -Class Win32_NetworkConnection | Out-File -Append -Encoding "UTF8" -FilePath filesystem.log
Run Code Online (Sandbox Code Playgroud)
似乎有 U:\ 潜伏在阴影中(在本地时不会出现)。这是已断开连接且不应再使用的网络驱动器。(有一些遗留程序使用它,它应该通过 GPO 规则应用)
net use产生:
U: \\server_name\U_login_name$ NFS Network
Run Code Online (Sandbox Code Playgroud)
[System.IO.DriveInfo]::GetDrives() | Format-Table产生:
Name DriveType DriveFormat IsReady AvailableFre TotalFreeSpa TotalSize RootDirecto VolumeLabel
eSpace ce ry
---- --------- ----------- ------- ------------ ------------ --------- ----------- -----------
C:\ Fixed NTFS True 1779298304 1779298304 ...43488000 C:\ OSDisk
U:\ Network False U:\
Run Code Online (Sandbox Code Playgroud)
Get-CimInstance -Class Win32_NetworkConnection
LocalName RemoteName ConnectionState Status
--------- ---------- --------------- ------
U: \\server_name\U_login_name$ Disconnected Unavailable
Run Code Online (Sandbox Code Playgroud)
另一方面,当直接在公司网络上时,就没有 U:\ 了。
手动断开
1)普通方式(右键断开连接)产生错误此网络连接不存在
2)使用NFS时umount u::
Disconnecting U: \\server_name\U_login$
There are open files and/or incomplete directory searches pending on the connection.
Do you want to continue this operation? (Y/N) [N]:y
Network Error - 2250 Not Connected
Run Code Online (Sandbox Code Playgroud)
3) 尝试强制断开所有 NFS 挂载(U:驱动器被报告为 NFS 共享)umount -f -a:
Network Error - 2250 Not Connected
Run Code Online (Sandbox Code Playgroud)在网上找到的建议:
1)更改GPO
要解决此问题,请通过组策略应用以下设置:
User Configuration/Administrative Templates/System/Scripts/Run logon scripts synchronously = Enabled
(注意:使用漫游配置文件时,计算机启动速度非常非常慢。必须禁用此设置)
2)映射的驱动器不会消失
我对此链接抱有很高的期望映射驱动器不会消失 - 登录时不断重新连接 我有与帖子中相同的感觉 - 引用:
> I have indeed checked scripts and GPOs and this is nowhere to be found there. This looks more like a manual mapping that had the
> "Reconnect on logon" checkbox checked and is now so persistent that
> there was no "normal" way to undo it.
Run Code Online (Sandbox Code Playgroud)
不幸的是,每一个建议都失败了。
注册表
1)我在注册表中搜索了该字符串并在这里找到了它:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2]。我尝试删除 U: 驱动器密钥,但它不断出现。
2)我也在这里找到了它(但还没有尝试过;我不想破坏操作系统):
Windows Registry Editor Version 5.00
[HKEY_USERS\S-1-5-21-119559289-1840127793-336618761-855951\Volatile Environment]
"HOMEDRIVE"="U:"
"LOGONSERVER"="\\\\logon_server"
"USERDNSDOMAIN"="dns_domain"
"USERDOMAIN"="user_domain"
"USERNAME"="login"
"USERPROFILE"="C:\\Users\\login"
"HOMEPATH"="\\"
"HOMESHARE"="\\\\server_name\\U_login$"
"APPDATA"="C:\\Users\\login\\AppData\\Roaming"
"LOCALAPPDATA"="C:\\Users\\login\\AppData\\Local"
"USERDOMAIN_ROAMINGPROFILE"="user_domain"
[HKEY_USERS\S-1-5-21-119559289-1840127793-336618761-855951\Volatile Environment\1]
"SESSIONNAME"="Console"
"CLIENTNAME"=""
Run Code Online (Sandbox Code Playgroud)
目前我的结论是我的漫游配置文件有问题。我还必须找到漫游配置文件未使用正确信息更新的原因。
有谁有想法/经验如何解决这样的问题?
最后希望知道原因并测试了一些场景。
首先声明一下,这是一个Windows NFS BUG。
我不知道如何以凡人的身份向微软报告。我将在这里和我的博客上报告它。
此错误传播需要满足一些条件:
1)计算机必须在域中
2) 您必须在内部网络和成熟的 VPN 上使用这台计算机,并且必须在同一配置文件上
3) 您必须安装 Microsoft 的 NFS 实现(别名 Client for NFS)
4)您必须让该服务在计算机启动时自动启动。如果服务处于manual启动状态并且在启动序列完成后启动,则该错误不会显现出来。
5)你必须有某种NFS共享。这里的问题是 NFS 共享优先于普通net use共享。如果您断开 NFS 共享,然后使用 映射它net use ... /persistent:yes,则重新启动后该共享将被覆盖。重新启动后,它将再次被识别为NFS 共享,并产生错误。
简而言之: 将NFS Client for Windows 服务从自动模式设置为手动。将任务计划程序或 gpedit 与我的 powershell 脚本结合使用来挂载和卸载 NFS 共享。 挂载某些共享时,请勿停止NFS Client for Windows 服务!
更长的答案:
使用我的脚本时请阅读以下信息:
注释&&最佳实践(阅读很重要!):
A) NFS mount, at least the Microsoft's implementation, is NOT persistent over boots. To overcome
this you have these options:
I) Schedule this script in Task scheduler under "ordinary" user e.g. DOMAIN\user and have the
check-box "Run with highest privileges" (in order to start the NFS Client service if stopped)
II) Run it in the "Local Group Policy Editor" (gpedit.msc) under "Windows Settings\Scripts"
(Startup -> mount and Shutdown -> unmount) in the sections "Computer Configuration" (for all
users) or under "User configuration" (for one specific user)
B) Do !!!NOT!!! mount NFS drive on system-wide account as "nt authority\system". At the first
glance this seems to be a good idea. Don't be fooled, it is not! When you mount NFS share
under "SYSTEM" account it will appear as fixed drive for all other users! On "SYSTEM" account
it still will show as network share. If you stop the NFS Client for Windows service, NOT
recommended when any NFS share active, and then start it again, then even under "SYSTEM"
account it will appear as "fixed" drive. It will leave user no option other than restart for
unmount.
C) It is NOT a good idea to stop Client for NFS Service when you have NFS mounted. It can lead
to unexpected states like the NFS share actually becoming a hard-drive for windows till reboot.
D) If the Client for NFS Service is started already then it is better not to stop it manually as
it can, under certain circumstances, refuse to start. It is better to have a log-off script
take care of the unmount && stopping the service
Run Code Online (Sandbox Code Playgroud)
错误或服务器配置说明:
A) You are getting a powershell error:
"Attempting to perform the InitializeDefaultDrives operation on the 'FileSystem' provider
failed."
This error can be caused the NFS Client for Windows when service is starting with start of the
Windows. It takes precedence over "ordinary" `net use` and it causes powershell to check
"FileSystem".
Run Code Online (Sandbox Code Playgroud)
Ad A) 解决方案:使用此脚本来安装 NFS 共享 - 在启动时使用 gpedit 策略设置它,或者
您可以通过任务计划程序运行(它尝试启动 NFS 服务客户端) - 该脚本必须有权这样做不要忘记将“NFS 客户端”(“NfsClnt”) 服务设置
为手动启动,这样它就不会随 Windows 启动而启动。
B) If you are getting this error message (at your NFS server):
"(rpc.mountd[7243]: refused mount request from 192.168.XX.XX for <mount>: illegal port 24784"
you are most probably trying to connect on port over 1024. To connect to NFS share you need
to have 'insecure' option at your /etc/exports (if missing fix it and run `exportfs -r`)
Run Code Online (Sandbox Code Playgroud)
提示:如果服务尚未启动,安装脚本需要 UAC 来启动服务。你可以:
Run Code Online (Sandbox Code Playgroud)1) run it manually - you will see UAC window 2) create a new Task in Task Scheduler and check the check box "Run it with highest privileges" 3) create a startup powershell script in the local policies
U:驱动器)当您打开脱机文件功能并将文件备份到网络驱动器时,可能会出现此问题。如果您的公司改变了这一点,转而使用某些云服务,那么当某些应用程序仍然需要以前的网络驱动器,但您仍然需要切换到新的云提供商时,它可能会给您的配置文件带来僵局。
如果您使用的NFS Client for windows是 Microsoft 的网络驱动器,则可以通过以下方式删除以前的网络驱动器:
通过以下步骤摆脱了U:驱动器(尚未显示消息):
1) 转到->Start Menu\Programs\Administrative Tools\Services for Network File System (NFS)
2)client for NFS右键单击该项目并选择停止stop service
3)简单的手动删除就可以了!!!!
net use u: /delete
--> U: was deleted successfully.
Run Code Online (Sandbox Code Playgroud)
为了使 Windows 忘记以前的驱动器并将易失性环境正确设置为新配置,您必须重新启动。
停止后不会出现错误消息Client for NFS。让它处于状态manual并通过脚本启动它就足够了
| 归档时间: |
|
| 查看次数: |
6207 次 |
| 最近记录: |