我需要使用Power
Shell在
Windows 7上创建一个共享网络文件夹 – 我无法访问New-SmbShare,因为这适用于Windows 8和Windows 2012 Server – 任何示例都会很棒.
我是否仅限于WMI通话?
复制粘贴就绪版本:
function New-Share ($foldername,$sharename) { if (!(test-path $foldername)) { new-item $foldername -type Directory } if (!(get-wmiObject Win32_Share -filter “name='$sharename'”)) { $shares = [WMICLASS]”WIN32_Share” if ($shares.Create($foldername,$sharename,0).ReturnValue -ne 0) { throw "Failed to create file share '$sharename'" } } }