Powershell New-NfsShare 无效的命名空间

Bmo*_*moe 5 powershell network-share

我正在尝试使用 New-NfsShare 命令创建网络共享,但我不断收到无效的命名空间错误。我从提供的例子中几乎是逐字逐句地写的,所以我不明白出了什么问题。

例子: New-nfsShare -Name "NFSshare01" -Path "C:\shares\NFSshare01"

我的代码: New-NfsShare -Name "LABS" -Path "C:\LABS" -Permission readwrite

有谁知道发生了什么?我已经将 NFS 模块导入到 Powershell 中,我什至尝试先创建目录,因为某些原因,该命令在进行网络共享之前无法创建该项目。我使用的是 Windows Server 2012 和 powershell 3.0 版

小智 8

我在我的两个 Windows 2012 系统上进行了测试。在没有NFS 服务器角色的服务器上,我收到相同的错误:

PS C:\> New-NfsShare -Name 'Temp' -Path 'C:\Temp' -Permission readwrite
New-NfsShare : Invalid namespace
At line:1 char:1
+ New-NfsShare -Name 'Temp' -Path 'C:\Temp' -Permission readwrite
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : MetadataError: (MSFT_NfsServerTasks:root/Microsoft/..._NfsServerTasks) [New-NfsShare], C
   imException
    + FullyQualifiedErrorId : HRESULT 0x8004100e,New-NfsShare
Run Code Online (Sandbox Code Playgroud)

但是在我安装该角色的系统上,它工作得很好(从提升的提示中执行):

PS C:\> New-NfsShare -Name 'Temp' -Path 'C:\Temp' -Permission readwrite

Name                                    Availability                            Path
----                                    ------------                            ----
Temp                                    Standard (not clustered)                C:\Temp
Run Code Online (Sandbox Code Playgroud)

检查以确保您的系统启用了该角色:

PS C:\Windows\system32> Get-WindowsFeature | Where-Object { $_.Name -match 'NFS' }

Display Name                                            Name                       Install State
------------                                            ----                       -------------
        [X] Server for NFS                              FS-NFS-Service                 Installed
[ ] Client for NFS                                      NFS-Client                     Available
            [X] Services for Network File System Man... RSAT-NFS-Admin                 Installed
Run Code Online (Sandbox Code Playgroud)