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 8927499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:14:02+00:00 2026-06-15T08:14:02+00:00

In a custom PowerShell module, I have at the top of my module definition

  • 0

In a custom PowerShell module, I have at the top of my module definition this code:

Update-FormatData -AppendPath (Join-Path $psscriptroot "*.ps1xml")

This is working fine as all .ps1xml files are loaded.

However, the module is sometimes loaded using Import-Module MyModule -Force (actually, this is in the install script of the module).

In this case, the call to Update-FormatData fails with this error :

Update-FormatData : There were errors in loading the format data file:
Microsoft.PowerShell, c:\pathto\myfile.Types.ext.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
At line:1 char:18
+ Update-FormatData <<<<  -AppendPath "c:\pathto\myfile.Types.ext.ps1xml"
    + CategoryInfo          : InvalidOperation: (:) [Update-FormatData], RuntimeException
    + FullyQualifiedErrorId : FormatXmlUpateException,Microsoft.PowerShell.Commands.UpdateFormatDataCommand

Is there a way to safely call this command?

I know I can call Update-FormatData with no parameters, and it will update any known .ps1xml file, but this would work only if the file has already been loaded.

Can I list somewhere the loaded format data files?

Here is a bit of background:

I’m building a custom module that is installed using a script. The install script looks like :

[CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact="High")]
param()
process {
    $target = Join-Path $PSHOME "Modules\MyModule"
    if ($pscmdlet.ShouldProcess("$target","Deploying MyModule module"))
    {
        if(!(Test-Path $target)) { new-Item -ItemType Directory -Path $target | Out-Null }
        get-ChildItem -Path (Split-Path ((Get-Variable MyInvocation -Scope 0).Value).MyCommand.Path) | copy-Item -Destination $target -Force

        Write-Host -ForegroundColorWhite @"

The module has been installed. You can import it using :

    Import-Module MyModule

Or you can add it in your profile ($profile)
"@

        Write-Warning "To refresh any open PowerShell session, you should run ""Import-Module MyModule -Force"" to reload the module"

        Import-Module MyModule -Force

        Write-Warning "This session has been refreshed."
    }
}

MyModule defines, as first statement, this line :

Update-FormatData -AppendPath (Join-Path $psscriptroot "*.ps1xml")

As I updated my $profile to always load this module, the Update-Path command has been called when I run the install script. In the install script, I force import the module, which be fire again the module, and then, the Update-Path call

  • 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-06-15T08:14:03+00:00Added an answer on June 15, 2026 at 8:14 am

    One easy way is use the -erroraction (alias -ea ) param:

    Update-FormatData -AppendPath (Join-Path $psscriptroot "*.ps1xml") -force -ea SilentlyContinue
    

    no error will be showed.

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

Sidebar

Related Questions

I have the following powershell script which loads a custom .NET DLL this contains
Is it possible to have custom datatype in powershell? I would like to have
I have a powershell build script which checks out code and increments a build
I found this function in my old powershell folder: Function listAllPaths([string]$fromFolder,[string]$filter) { Get-ChildItem -Path
I have a custom C# PowerShell Cmdlet (inheriting from the Cmdlet base class) and
I have created some custom PowerShell Cmdlets in C# and would like to provide
I have a custom PowerShell runspace from which I execute a script (simplified): Pipeline
I'm pretty new to powershell. I've built a custom cmdlet. I already have it
I'd like to call a PowerShell script this way : script.ps1 -path mypath\to\files\ -days
I'm trying to write a custom powershell script that will create a local user

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.