Remotely invoke User Policy Retrieval & Evaluation Cycle and other Configuration Manager Actions

I wrote a function that I use to invoke all of the Configuration Manager Actions on remote devices. I noticed that all of the configuration manager actions can be invoked in a similar manner except for “User Policy Retrieval & Evaluation Cycle”, at the time I did some research and it seemed like it was working, but has since began to throw errors.

When the script is iterating through the devices it always succeeds on the first device then fails on any following devices, but only for the User Policy Retrieval portion. If I try to run it locally/remotely on a single device it works fine.

The error I am receiving:

Cannot convert value "rootccmPolicyS_1_5_21_81564394_10899842_11037298_5564ActualConfig:CCM_Scheduler_ScheduledMessage.ScheduledMessageID='{00000000-0000-0000-0000-000000000027}'" to type "System.Management.ManagementObject". Error: "Invalid namespace "

Function for initializing CM Actions:

Function Initialize-CMActions {

    Write-Host "`tInitializing Configuration Manager Actions." -ForegroundColor Yellow

    [System.Collections.ArrayList]$Actions = @(
        [PSCustomObject]@{ID = "{00000000-0000-0000-0000-000000000121}";Name = "Application Deployment Evaluation Cycle"},
        [PSCustomObject]@{ID = "{00000000-0000-0000-0000-000000000003}";Name = "Discovery Data Collection Cycle"},
        [PSCustomObject]@{ID = "{00000000-0000-0000-0000-000000000001}";Name = "Hardware Inventory Cycle"},
        [PSCustomObject]@{ID = "{00000000-0000-0000-0000-000000000021}";Name = "Machine Policy Retrieval & Evaluation Cycle"},
        [PSCustomObject]@{ID = "{00000000-0000-0000-0000-000000000031}";Name = "Software Metering Usage Report Cycle"},
        [PSCustomObject]@{ID = "{00000000-0000-0000-0000-000000000114}";Name = "Software Updates Deployment Evaluation Cycle"},
        [PSCustomObject]@{ID = "{00000000-0000-0000-0000-000000000113}";Name = "Software Updates Scan Cycle"},
        [PSCustomObject]@{ID = "{00000000-0000-0000-0000-000000000027}";Name = "User Policy Retrieval & Evaluation Cycle"},
        [PSCustomObject]@{ID = "{00000000-0000-0000-0000-000000000032}";Name = "Windows Installer Source List Update Cycle"}
    )

    Foreach ($Action in $Actions)
    {
        #If Action is User Policy Retrieval
        if ($Action.ID -eq "{00000000-0000-0000-0000-000000000027}")
        {
            Try
            {
                #Invoke User Policy Retrieval & Evaluation Cycle using sid S_1_5_21_81564394_10899842_11037298_5564
                Invoke-command -ComputerName $($Workstation.SN) -ScriptBlock {
                    $sched=([wmi]"rootccmPolicyS_1_5_21_81564394_10899842_11037298_5564ActualConfig:CCM_Scheduler_ScheduledMessage.ScheduledMessageID='{00000000-0000-0000-0000-000000000027}'")
                    $sched.Triggers=@('SimpleInterval;Minutes=1;MaxRandomDelayMinutes=0') | Out-Null;
                    $sched.Put() | Out-Null;
                } -ErrorAction Stop
                Write-Host "`t`tInitialized User Policy Evaluation Cycle" -ForegroundColor Green
            }
            Catch
            {
                Write-Host "`t`tUnable to initialize User Policy Retrieval & Evaluation Cycle for SID - S_1_5_21_81564394_10899842_11037298_5564" -ForegroundColor Red
                Write-Host "$_"
            }
        }
        Else
        {
            Try
            {
                Invoke-Command -ComputerName $($Workstation.SN) {Invoke-WmiMethod -namespace rootccm -class sms_client -name TriggerSchedule $using:Action.ID | Out-Null}
                Write-Host "`t`tInitialized $($Action.Name)" -ForegroundColor Green
            }
            Catch
            {
                Write-Host "`t`tUnable to initialize $($Action.Name)" -ForegroundColor Red
                $_
            }
        }
    }
}

Is there something in this function that I am missing causing a memory leak or variable mismatch? I normally like to figure out my mistakes on my own, but I have spent so many hours trying to figure this out and I can’t seem to find any of the previous resources I used to piece together how to initialize the User Policy Retrieval & Evaluation Cycle.

All criticisms, insights, and answers are welcome!

0

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật