尝试打开上次修改的文件时出现Powershell错误

时间:2016-02-09 12:42:52

标签: powershell

因此,我试图从服务器上的另一台计算机中提取程序的数据主义者,并将其转换为计算机中某个位置的csv文件。那部分是成功的,但是当我试图打开最新创建的csv与powershell即时面临一个错误。

<#User details#>
$user = „administrator“
$password = cat filesystem::c:\Users\praktikant2\Desktop\mingifail.txt | convertto-securestring
$me = new-object -typename System.Management.Automation.PSCredential -argumentlist $user, $password   

$list = Invoke-Command -cn Fillerhere -ScriptBlock {Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | select DisplayName, Publisher, Version, EstimatedSize, UninstallString} -Credential $me
$list | Select-Object DisplayName, Publisher, Version, EstimatedSize, UninstallString | Export-Csv -Path C:\Users\praktikant2\Desktop\Loetelud\progloetelu$((get-date).tostring('dd-MM-yyyy-hh-mm-ss')).csv -Encoding ascii -NoTypeInformation -Delimiter ';'  
$excel = New-Object -ComObject Excel.application
$path = gci C:\Users\praktikant2\Desktop\Lists | sort LastWriteTime | select -last 1  
$excel.Visible = $false
$openfile = $excel.workbooks.open($path);

错误消息(有点粗略翻译)它甚至似乎识别出创建的文件,因为它命名了指定位置中存在的正确文件

Exception calling "Open" with "1" argument(s): "Unit progloetelu09-02-2016-02-16-02.csv not found. Is it possible that it's been moved,renamed or deleted?"
At line:16 char:1

 + $openfile = $excel.workbooks.open($path);
 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : ComMethodTargetInvocation

0 个答案:

没有答案