/PowerShell-utilities

Powershell utilities for System Administrators or IT technical support

Primary LanguagePowerShellApache License 2.0Apache-2.0

Powershell utilities for System Administrators or TI technical support

How to use

These scripts are only for Windows 10:

Execute PowerShell as administrator, you must enable the execution of scripts for this you must write:

Set-ExecutionPolicy Unrestricted

How to run the scripts

Already with powershell running you must put the path of the script, for example:

C:\TestPS.ps1

The utilities

1. Working with DSN ODBC

Import DSN:

$user_profile = [Environment]::GetFolderPath([Environment+SpecialFolder]::UserProfile)
$dsn_folder = $user_profile + "\Desktop\"
$dsn_file = $dsn_folder + "dsn.xml"

Import-Clixml $dsn_file |Add-OdbcDsn

Export DSN:

$user_profile = [Environment]::GetFolderPath([Environment+SpecialFolder]::UserProfile)
$dsn_folder = $user_profile + "\Desktop\"
$dsn_file = $dsn_folder + "dsn.xml"

Get-OdbcDsn |Export-Clixml $dsn_file

2. Enable Windows Optional Features

Enable a feature such as NetFx3:

Enable-WindowsOptionalFeature -Online -FeatureName "NetFx3"

3. Check Windows 10 version

To know that just write:

Get-ComputerInfo | Select-Object WindowsProductName

4. Backup and recovery of entire Thunderbird client email accounts

The script facilitates the copying of the data, creates a file with the extension PS1 and places code inside, with option 1 the script exports the data to the Desktop path, copies that folder to the Desktop path of the computer where you are going to import the data, before executing the script you must have Thunderbird installed, finally select option 2 to import.

$user_profile = [Environment]::GetFolderPath([Environment+SpecialFolder]::UserProfile)
$app_data = [Environment]::GetFolderPath([Environment+SpecialFolder]::ApplicationData)
$thunderbird = $app_data + "\Thunderbird"
$to_desktop = $user_profile + "\Desktop\backup_Thunderbird"
$selection = Read-Host -Prompt "Enter 1 for export or 2 for Import"

If ($selection  -eq '1') {
    Write-Host "Export Thunderbird configuration folder to desktop"
    Copy-Item $thunderbird -Recurse -Destination $to_desktop
} ElseIf ($selection  -eq '2') {
    Write-Host "Import 'backup_Thunderbird' folder from desktop"
    Copy-Item $to_desktop -Recurse -Destination $thunderbird
} Else {
    Write-Host "Incorrect selection"
}

5. Uninstall Windows updates on windows 10

wusa /uninstall /kb:123456