运行powershell脚本时出错
运行powershell脚本时出现以下错误。我想这以前是很糟糕的。任何想法都可能是个问题运行powershell脚本时出错,powershell,Powershell,运行powershell脚本时出现以下错误。我想这以前是很糟糕的。任何想法都可能是个问题 Set-Content : The network name cannot be found. At C:\inetpub\IISscripts\SubIndexGenHyperlinksInHtml.ps1:20 char:18 + } | Set-Content <<<< "$fldr.htm" + CategoryInfo : WriteErro
Set-Content : The network name cannot be found.
At C:\inetpub\IISscripts\SubIndexGenHyperlinksInHtml.ps1:20 char:18
+ } | Set-Content <<<< "$fldr.htm"
+ CategoryInfo : WriteError: (\\nclient\diskuse.htm:String) [Set-Content], IOException
+ FullyQualifiedErrorId : GetContentWriterIOError,Microsoft.PowerShell.Commands.SetContentCommand
设置内容:找不到网络名称。
在C:\inetpub\iiscripts\SubIndexGenHyperlinksInHtml.ps1:20 char:18
+}集合内容
找不到网络名称。
您正在远程(网络)文件夹上执行Get ChildItem
:名称查找失败。可能服务器不可用或无法访问。$fldr
是一个文件夹,即:
$fldr = \\nclient\diskuse
Set-Content "$fldr.htm"
尝试在此路径中保存\\n客户端
此文件diskuse.htm
我检查了网络驱动器是否可用以及读写权限是否正确。我还更新了我的问题,提供了更多细节。
$basedir = '\\nclient\diskuse'
$exp = [regex]::Escape($basedir)
$server = 'http://nclient/diskuse'
Get-ChildItem $basedir -Force | ? { -not $_.psiscontainer } |
select Name, LastWriteTime,
@{n="URL";e={$_.FullName -replace $exp, $server -replace '\\', '/'}} |
ConvertTo-Html -Fragment URL, Name, LastWriteTime `
-PreContent '<html><head><style>BODY{background-color:#A987CC;}
TABLE cellpadding="2"{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;.center { margin:auto; width:70%; };}
TH{border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color:#99CCFF}
TD{border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color:PaleGoldenrod}</style><title>User</title></head><body>' `
-PostContent '</body></html>' |
% { $_ -replace '<th>.*</th>','<th>COMPUTERS</th>' `
-replace '<td>(.*?)</td><td>(.*?)</td><td>(.*?)</td>',
'<td><a href="$1">$2</a> $3</td>'
} | Set-Content "\\nclient\diskuse\index.htm"
# this is server-side index page generating code
$fldr = \\nclient\diskuse
Set-Content "$fldr.htm"