无法在PowerShell中导出表?

无法在PowerShell中导出表?,powershell,Powershell,好的,到目前为止,PowerShell的一切都非常棒,但是对于一些非常棒的东西,他们确实让导出结果到文件变得非常复杂。无论如何,如何将Export$Results变量导入到已删除的文件中,以便将其导入 定稿 使用 尝试: 导出csv无法导出字符串或其他内容,我尝试了各种组合,但始终无法使导出csv正常工作。-append在Powershell v2中不起作用,但我删除了它,一切都很好。谢谢! [cmdletbinding()] [cmdletbinding()] param( [par

好的,到目前为止,PowerShell的一切都非常棒,但是对于一些非常棒的东西,他们确实让导出结果到文件变得非常复杂。无论如何,如何将Export$Results变量导入到已删除的文件中,以便将其导入

定稿 使用

尝试:


导出csv无法导出字符串或其他内容,我尝试了各种组合,但始终无法使导出csv正常工作。-append在Powershell v2中不起作用,但我删除了它,一切都很好。谢谢!
[cmdletbinding()]

[cmdletbinding()]
param(
    [parameter(ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
    [string[]]$ComputerName = "HellBombs-PC"
)

begin {
    $UninstallRegKey="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
}

process {
    foreach($Computer in $ComputerName) {
        Write-Verbose "Working on $Computer"
        if(Test-Connection -ComputerName $Computer -Count 1 -ea 0) {
            $HKLM   = [microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine',$computer)
            $UninstallRef  = $HKLM.OpenSubKey($UninstallRegKey)
            $Applications = $UninstallRef.GetSubKeyNames()

            foreach ($App in $Applications) {
                $AppRegistryKey  = $UninstallRegKey + "\\" + $App
                $AppDetails   = $HKLM.OpenSubKey($AppRegistryKey)
                $AppGUID   = $App
                $AppDisplayName  = $($AppDetails.GetValue("DisplayName"))
                $AppVersion   = $($AppDetails.GetValue("DisplayVersion"))
                $AppPublisher  = $($AppDetails.GetValue("Publisher"))
                $AppInstalledDate = $($AppDetails.GetValue("InstallDate"))
                $AppUninstall  = $($AppDetails.GetValue("UninstallString"))
                if(!$AppDisplayName) {
                    continue
                }
                $OutputObj = New-Object -TypeName PSobject
                $OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Computer.ToUpper()
                $OutputObj | Add-Member -MemberType NoteProperty -Name AppName -Value $AppDisplayName
                $OutputObj | Add-Member -MemberType NoteProperty -Name AppVersion -Value $AppVersion
                $OutputObj | Add-Member -MemberType NoteProperty -Name AppVendor -Value $AppPublisher
                $OutputObj | Add-Member -MemberType NoteProperty -Name InstalledDate -Value $AppInstalledDate
                $OutputObj | Add-Member -MemberType NoteProperty -Name UninstallKey -Value $AppUninstall
                $OutputObj | Add-Member -MemberType NoteProperty -Name AppGUID -Value $AppGUID
                $Result += @($OutputObj)
            }
        }
    }
    $Result | select -Property * | export-csv -notypeinformation -path Info.txt
}

end {}
$Result | select -Property * | export-csv -notypeinformation -append -path .\test.txt