Atlas.ClientToolKit.psm1

<#
    ===========================================================================
     Created with: SAPIEN Technologies, Inc., PowerShell Studio 2021 v5.8.191
     Created on: 6/25/2021 9:38 AM
     Created by: Justin DeBusk
     Organization: Atlas Network Services, LLC.
     Filename: Atlas.ClientToolKit.psm1
    -------------------------------------------------------------------------
     Module Name: Atlas.ClientToolKit
    ===========================================================================
#>



#region Sets the computer name
function Set-ComputerName
{
    param ([Parameter(Mandatory = $true)]
        [ValidateNotNull()]
        $computerName)
    
    try
    {
        Rename-Computer -NewName $computerName
    }
    catch
    {
        [System.Windows.Forms.MessageBox]::Show("There was an error setting the new computer name. `n `n In Module: Atlas.ClientToolKit", "Error", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Error)
    }
}
#endregion

#region Set UAC to disabled
function Set-UACToDisable
{
    try
    {
        # Disable UAC
        New-ItemProperty -Path HKLM:Software\Microsoft\Windows\CurrentVersion\policies\system -Name EnableLUA -PropertyType DWord -Value 0 -Force
    }
    catch
    {
        
    }
}
#endregion

#region Sets the lid closing setting
function Set-LidCloseSetting
{
    try
    {
        # Sets "When I close the lid:" setting to do nothing when on AC power
        & cmd.exe /c "powercfg -setacvalueindex SCHEME_CURRENT 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 0"
    }
    catch
    {
        [System.Windows.Forms.MessageBox]::Show("Something went wrong! `n `n In Module: Atlas.ClientToolKit", "Error", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Error)
    }
}
#endregion

#region Sets the power button setting
function Set-PowerButtionSettings
{
    try
    {
        # Sets "When I press the power button:" setting to do nothing when on AC power
        & cmd.exe /c "powercfg -setacvalueindex SCHEME_CURRENT 4f971e89-eebd-4455-a8de-9e59040e7347 7648efa3-dd9c-4e3e-b566-50f929386280 3"
    }
    catch
    {
        [System.Windows.Forms.MessageBox]::Show("Something went wrong! `n `n In Module: Atlas.ClientToolKit", "Error", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Error)
    }
}
#endregion

#region Sets the sleep settings
function Set-SleepSettings
{
    try
    {
        & cmd.exe /c "powercfg -change -standby-timeout-ac 0"
        & cmd.exe /c "powercfg -change -disk-timeout-ac 0"
    }
    catch
    {
        [System.Windows.Forms.MessageBox]::Show("Something went wrong! `n `n In Module: Atlas.ClientToolKit", "Error", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Error)
    }
}
#endregion

#region Write to the log file
function Write-LogFile
{
    param ([Parameter(Mandatory = $true)]
        [ValidateNotNull()]
        $logFile,
        [Parameter(Mandatory = $false)]
        $user,
        [Parameter(Mandatory = $true)]
        [ValidateNotNull()]
        $message
    )
    
    if (!($message -eq $null))
    {
        Add-Content $logFile "$(Get-Date) $user $message"
    }
}
#endregion