Monday, August 26, 2024

To Remove Disconnected Session

 function Remove-DisconnectedSessions {

    # Get all user sessions on the machine

    $sessions = query user

    foreach ($session in $sessions) {

        # Split the session details into an array

        $sessionDetails = $session -split '\s+'

        # Check if the session state is 'Disc' (Disconnected)

        if ($sessionDetails[3] -eq 'Disc') {

            $sessionId = $sessionDetails[2]

            # Log off the disconnected session

            logoff $sessionId

            Write-Host "Disconnected session with ID $sessionId has been logged off."

        }

    }

}

Remove-DisconnectedSessions



This can be used in SCCM Script and run against any Device collection

Temporary Admin Rights Script for SCCM/ MECM

Script for Granting Temporary Admin Rights for End User's

The  Temporary Admin Rights script has been enhanced to grant temporary administrative rights to the currently logged-in user. The script identifies the user by determining the owner of the explorer.exe process and adds them to the local administrators' group with a set timer. Once the timer expires, the user is automatically removed from the admin group. Additionally, the script includes a GUI with a button that allows the user to extend the admin rights by 30-minute increments, up to a maximum of 6 hours.

Key Features:

User Identification: The script identifies the currently logged-in user by finding the owner of the explorer.exe process.

Admin Rights Management: Admin rights are granted using the PowerShell Add-LocalGroupMember cmdlet, and they are removed using the Remove-LocalGroupMember cmdlet. The use of PowerShell avoids the appearance of a command prompt window on the desktop.

Timer Functionality: A timer counts down the time remaining for the admin rights. Once the timer runs out, the user is removed from the admin group.

GUI Interface: The script includes a graphical interface that displays the time remaining in hours, minutes, and seconds. It also provides an "Add 30 minutes" button to extend the timer.

Deployment in SCCM: The script was packaged as an SCCM application / package and configured to run in the user context. Extensive testing confirmed that the script works as intended, providing a seamless experience for users requiring temporary administrative privileges.




Script is available to download from GitHub











Friday, August 16, 2024

Enhancing SCCM/MECM AD Group Deployment with Our Upgraded PowerShell Tool

I'm excited to share the latest update to our PowerShell tool designed for SCCM/MECM AD Group deployments. This upgrade brings several new features and improvements that enhance our deployment processes and streamline our workflow.

Key Features of the Upgraded Tool:


1. Dual Deployment Capability: Previously, our tool only supported application deployments. With this upgrade, it now supports both application and package deployments, providing greater flexibility and efficiency.


2. New Collection Creation: The tool can now create new collections, making it easier to organize and manage deployments. Once the collection is created, the tool can deploy applications and packages to it seamlessly.


3. Support for Existing AD Group Collections: In addition to creating new collections, the tool can also deploy applications and packages to existing AD group collections, simplifying the integration with our current infrastructure.


4. Automated Collection Variables: To ensure smooth deployments, the tool adds collection variables automatically, reducing the need for manual intervention and minimizing errors.


5. Proper Folder Placement: The tool ensures that both applications and packages, along with collections, are placed in the correct folders within SCCM. This organization helps maintain a tidy and efficient deployment environment.


6. Automated Deployment Creation: After performing all the above steps, the tool automatically creates the deployment, saving valuable time and effort.


7. Email Notifications for Validation: The tool will continue to send email notifications with the same details as before for validation of the deployment, ensuring that our processes remain transparent and verified.


8. User Collection Creation: The tool can now create user collections and deploy to them. Simply enable the "If user" checkbox to utilize this feature.


Conclusion:

These enhancements are designed to improve our deployment processes, increase accuracy, and save time. By automating several key steps, we can focus on more strategic tasks and ensure our deployment operations run smoothly.


Feel free to reach out if you have any questions or need more information about the upgraded tool.


Here is the image from the tool.




Here is the link to download the Script

Trigger remote machine SCCM Baseline

 function Invoke-BLEvaluation {  param (  [String][Parameter(Mandatory=$true, Position=1)] $ComputerName,  [String][Parameter(Mandatory=$Fal...