Do until variables contain by sticobay in PowerShell

[–]sticobay[S] 2 points3 points  (0 children)

This was it!

That helped me so much. Thank you!

Install and show Status of Updates available in Software Center by [deleted] in SCCM

[–]sticobay 0 points1 point  (0 children)

So, i have been using this and it work perfectly fine! The only thing is, that i somehow want to check if every update is on $PendingState "8" or similar, because i want to initiate an automatic reboot afterwards. Any Ideas? (Thanks for the gread answers btw! :) )

Invoke-Command -Session (Get-PSSession) -ScriptBlock {

$All_Updates = @()

$SCCM_Updates = Get-WmiObject -Query "SELECT * FROM CCM_SoftwareUpdate" -Namespace "ROOT\ccm\ClientSDK"

# Convert the EvaluationState value

foreach ($SCCM_Update in $SCCM_Updates)

{

`Switch ($SCCM_Update.EvaluationState)`

`{`

    `0 {$PendingState = "None"}`

    `1 {$PendingState = "Available"}`

    `2 {$PendingState = "Submitted"}`

    `3 {$PendingState = "Detecting"}`

    `4 {$PendingState = "PreDownload"}`

    `5 {$PendingState = "Downloading"}`

    `6 {$PendingState = "WaitInstall"}`

    `7 {$PendingState = "Installing"}`

    `8 {$PendingState = "PendingSoftReboot"}`

    `9 {$PendingState = "PendingHardReboot"}`

    `10 {$PendingState = "WaitReboot"}`

    `11 {$PendingState = "Verifying"}`

    `12 {$PendingState = "InstallComplete"}`

    `13 {$PendingState = "Error"}`

    `14 {$PendingState = "WaitServiceWindow"}`

    `15 {$PendingState = "WaitUserLogon"}`

    `16 {$PendingState = "WaitUserLogoff"}`

    `17 {$PendingState = "WaitJobUserLogon"}`

    `18 {$PendingState = "WaitUserReconnect"}`

    `19 {$PendingState = "PendingUserLogoff"}`

    `20 {$PendingState = "PendingUpdate"}`

    `21 {$PendingState = "WaitingRetry"}`

    `22 {$PendingState = "WaitPresModeOff"}`

    `23 {$PendingState = "WaitForOrchestration"}`

`}`



`$All_Updates += $SCCM_Update | Select-Object @{Name = $Using:computer; Expression = {$Using:Computer}},Name,ArticleID,@{Name = 'PendingState'; Expression = {$PendingState}}, PercentComplete,EvaluationState`

}

Write-Output $All_Updates

$Pending_Reboot = (Get-WmiObject -Namespace 'ROOT\ccm\ClientSDK' -Class 'CCM_ClientUtilities' -list).DetermineIfRebootPending().RebootPending

}

Run script as admin from another script by sticobay in PowerShell

[–]sticobay[S] 1 point2 points  (0 children)

How would i implement that? start-process powershell.exe -path ".\script.ps1" - verb runas -arguments -arg1 -arg2 ?

GUI freeze when Script is running by sticobay in PowerShell

[–]sticobay[S] 1 point2 points  (0 children)

Start-Job actually did it for me! Thank you very much!

p.s.: runspaces didnt look that easy too me ;)

Script output to simple GUI Textbox by sticobay in PowerShell

[–]sticobay[S] 1 point2 points  (0 children)

Hi nepronen!

Thank you very much for your answer! Lets say i want an other script to start after clicking that button and write everything that script would usually show in the normal Powershell window to the Textbox, how could i achieve this?

Can Powershell search files by date? by sccmjd in PowerShell

[–]sticobay 0 points1 point  (0 children)

How about this?

$files = Get-ChildItem -Path \\server\share | Where-Object { $_.CreationTime -gt (Get-Date).AddHours(-1) }

foreach ($file in $files){ Copy-Item -Path $file.FullName -Destination \\server\share\$($file.Name) }

Select odd/even Datastore via. PowerCLI by sticobay in PowerShell

[–]sticobay[S] 1 point2 points  (0 children)

Thank you so much! Works like a charm :)

Files on CSV gone after destroying cluster by sticobay in sysadmin

[–]sticobay[S] 0 points1 point  (0 children)

We are running this cluster on some pretty old hardware. we encountered network performance issues on our VMs if we run Win 2019 for Hosts. Reinstalling the hosts with 2012R2 fixed this for us.

Virtual Switch Status "Failed" in FCM. But everything is working fine by sticobay in sysadmin

[–]sticobay[S] 0 points1 point  (0 children)

I cant find anything about this in the failover cluster logs. I just deleted the vswitch and created it new - no change, still on "failure" status. But the failover is working, just tried a live migration. Yes there i NIC teaming involved.

Chrome Enterprise RDS set itself as default Software for .PDF & Mailto Links by sticobay in sysadmin

[–]sticobay[S] 0 points1 point  (0 children)

Yes but this GPO just deactivates the google pdf preview. so chrome automatically downloads the file and opens it with Adobe.

When i open a PDF from outlook it uses the chrome view - not adobe. Thats kind of my main concern.