Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6234489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:29:42+00:00 2026-05-24T10:29:42+00:00

I am writing a PowerShell provider in C#. The provider exposes an applications domain

  • 0

I am writing a PowerShell provider in C#. The provider exposes an applications domain objects through a drive-like interface. For example:

my:\Users\joe@blow.com
my:\Customers\Marty

This data ultimately comes from a database.

I have been unable to find any great guidance for when you should go to the database for data, and when you should cache it. I find that PowerShell calls methods like ItemExists and GetChildNames many times; often repeatedly for the same command. It is impractical to go to the database 5 or 6 times just because they hit Tab for auto-complete, for example.

But at the same time, as a user at the command prompt, if I type Get-ChildItem (dir) and see the list, then do something outside PowerShell so that I know the data is refreshed, taking another directory listing should expect to see any changes to the database.

I feel that if I knew the right term to describe my problem (in PowerShell parlance) I would be able to Google the answer or find an existing duplicate question, but I’m stuck.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:29:43+00:00Added an answer on May 24, 2026 at 10:29 am

    This has very little to do with powershell and everything to do with your data, and how important it is to refresh it. A simple caching scheme would be to use a time based system whereby after N minutes, a request to your back end’s data layer would pull a fresh copy and reset the timer. It seems you already have an idea what your particular rules should be. I don’t think two successive “dir” commands should always result in two pulls from the backing store, but you do think so for your system. So make it so.

    UPDATE

    Perhaps a simple guiding principle might be that you should only refresh your data once per provider command issued. The list of built-in commands that operate on provider items consists of:

    • Clear-Item
    • Copy-Item
    • Get-Item
    • Invoke-Item
    • Move-Item
    • New-Item
    • Remove-Item
    • Rename-Item
    • Set-Item

    Additionally, the list of built-in commands that operate on provider item properties consists of:

    • Clear-ItemProperty
    • Copy-ItemProperty
    • Get-ItemProperty
    • Move-ItemProperty
    • New-ItemProperty
    • Remove-ItemProperty
    • Rename-ItemProperty
    • Set-ItemProperty

    And finally, for reading/writing content, we use:

    • Add-Content
    • Clear-Content
    • Get-Content
    • Set-Content

    Each of these commands has a corresponding method in NavigationCmdletProvider (for hierarchical datastores) and this is where you might want to refresh your data. When implementing the New/Move/Rename/Remove/Set/Clear and other data changing methods, you should use some kind of optimistic concurrency methodology as provider instances in PowerShell are not singletons; there may be one or more instances in play at any time.

    I wrote a provider that takes its implementation from script that you may find easier to prototype things in. See http://psprovider.codeplex.com/

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a NavigationCmdletProvider for PowerShell. Through the GetItem and GetChildItems overrides, there are
I'm writing a powershell v2 script that I'd like to run against a remote
I'm writing a custom PowerShell cmdlet, and I would like to know which is
I'm writing some Powershell scripts so we can monitor our SQLServer instances through Nagios,
I'm writing an application that can run PowerShell scripts which I'd like to be
I'm writing some PowerShell scripts to work with our source control software (which is
I am writing a PowerShell script that will back up several folders from my
I'm writing a powershell script for deployment. I need to copy changed files from
I am writing a script for MS PowerShell. This script uses the Copy-Item command.
I'm writing a GUI tool using PowerShell that is able to do most AD

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.