none
'Cannot open file because the current provider issue' with Powershell cmdlet RRS feed

  • Question

  • I need to run below script to check certificate expired date remotely, but it didn't work with the error message. I made net share folder 'E:\Certmon' as '\\Server\Certmon'. 

    PS cert:\LocalMachine> GET-CHILDITEM -RECURSE | where {$_.PSParentPath -like '*localmachine\My*'  -AND $_.notafter -le (get-date).AddDays(99999) -AND $_.notafter -gt (get-date) }  | select subject, notafter |  export-csv -path \\SERVER\certmon\et.csv -NoTypeInformation
    Export-Csv : Cannot open file because the current provider (Microsoft.PowerShell.Security\Certificate) cannot open a file.
    At line:1 char:198
    + GET-CHILDITEM -RECURSE | where {$_.PSParentPath -like '*localmachine\My*'  -AND $_.notafter -le (get-date).AddDays(99999) -AND $_.notafter -gt (get-date) }  | select subject, notafter |  export-csv <<<<  -path \\Server\certmon\et.
    csv -NoTypeInformation
        + CategoryInfo          : InvalidArgument: (:) [Export-Csv], PSInvalidOperationException
        + FullyQualifiedErrorId : ReadWriteFileNotFileSystemProvider,Microsoft.PowerShell.Commands.ExportCsvCommand

    However, when I run the script without net share, it works. 

    GET-CHILDITEM -RECURSE | where {$_.PSParentPath -like '*localmachine\My*'  -AND $_.notafter -le (get-date).AddDays(99999) -AND $_.notafter -gt (get-date) }  | Ft subject, notafter |  export-csv -path E:\certmon\$(get-date -f yyyy-MM-dd).csv -NoTypeInformation -Encoding "UTF8"
    Do you have any idea to solve this issue?



    • Edited by 100Panda Thursday, July 20, 2017 12:41 AM
    Thursday, July 20, 2017 12:38 AM

Answers

  • You can't share the cert store.  The cert store can only be accessed locally via the PowerShell cert provider.

    You can use certutil to read stores or you can use the cert API to remotely read stores.


    \_(ツ)_/


    • Edited by jrv Thursday, July 20, 2017 1:27 AM
    • Marked as answer by 100Panda Thursday, July 20, 2017 6:08 AM
    Thursday, July 20, 2017 1:25 AM

All replies

  • You can't share the cert store.  The cert store can only be accessed locally via the PowerShell cert provider.

    You can use certutil to read stores or you can use the cert API to remotely read stores.


    \_(ツ)_/


    • Edited by jrv Thursday, July 20, 2017 1:27 AM
    • Marked as answer by 100Panda Thursday, July 20, 2017 6:08 AM
    Thursday, July 20, 2017 1:25 AM
  • You can't share the cert store.  The cert store can only be accessed locally via the PowerShell cert provider.

    You can use certutil to read stores or you can use the cert API to remotely read stores.


    \_(ツ)_/


    Thanks for your support. 
    Thursday, July 20, 2017 6:08 AM