0

PowerShell スクリプトを実行すると、次のエラーが発生します。前は週だったと思います。何が問題になる可能性があるかについてのアイデア!

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

Powershell コードは次のとおりです。

$basedir = '\\nclient\diskuse'
$exp     = [regex]::Escape($basedir)
$server  = 'http://nclient/diskuse'

# This is server-side SubIndex page generating code

function Create-HtmlList($fldr) {
  Get-ChildItem $fldr -Force | sort-object -property LastWriteTime -Descending |
    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>SCAN BY DATE</th>' `
         -replace '<td>(.*?)</td><td>(.*?)</td><td>(.*?)</td>',
                  '<td><a href="$1">$2</a> $3</td>'
  } | Set-Content "$fldr.htm"
}

# list files in $basedir:
Create-HtmlList $basedir

# list files in all subfolders of $basedir:
Get-ChildItem $basedir -Recurse -Force |
  ? { $_.PSIsContainer } |
  % {
    Create-HtmlList $_.FullName
  }

次のスクリプトも問題なく実行しています。

$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
4

2 に答える 2

0

$fldrフォルダの場合、つまり:

$fldr = \\nclient\diskuse
Set-Content "$fldr.htm" 

このパスに\\nclientこのファイルを保存してみてくださいdiskuse.htm

于 2013-09-18T09:13:59.400 に答える