Deleting Multiple Files in DSC

Welcome Forums DSC (Desired State Configuration) Deleting Multiple Files in DSC

This topic contains 1 reply, has 2 voices, and was last updated by

2 years ago.

  • Author
  • #64404

    Points: 0
    Rank: Member

    Hey Guys!

    I was wondering if there was a way to delete multiple files in a directory, but not ALL the files. I know That with the dsc File resource you can delete the contents of a directory with the recurse=$true statement, but lets say I had 3 files in a directory named


    And I only wanted to delete the files with the numbers in them. I tried using this value in the DestinationPath:

    DestinationPath = "C:\Users\******\Desktop\MISC\example_log_test_folder\file.txt.*"

    But powershell returned thsi to me:

    Wildcard characters are not supported in DestinationPath property.
    + CategoryInfo : NotImplemented: (:) [], CimException
    + FullyQualifiedErrorId : MI RESULT 7
    + PSComputerName : localhost

    So I assume that powershell dsc doesnt recognize wildcards for manipulating multiple objects I think. So is there a way to delete multiple files with out having to declare a bunch of dsc statements?

  • #64410

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    You'd need to do a custom resource, or a Script resource.

The topic ‘Deleting Multiple Files in DSC’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort