Tag: Powershell

  • Use Command Line to View Saved Wi-Fi Passwords on Windows 10

    Above commands work in cmd or powershell on a Win10 box, remember you’ll have to run it as an administrator.

  • Powershell Function to Get Sizes of All Databases on an Instance

    Below is a function that I modified from one in Idera’s SQL Server Powershell Scripts toolset: [sourcecode language=”powershell”] #Function to get sizes of all DB’s hosted on an instance Function Get-SQLDBSizes { param ( [string]$InstaceName = "$(Read-Host ‘Please use format ServerName(IPAddress)\InstanceName’ [e.g. 127.0.0.1\instance])" ) begin { [void][reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") } process { try { Write-Verbose "Connect to…

  • Powershell Function to Get the Last Boot Up Time of a Computer

    [sourcecode language=”powershell” wraplines=”false”] #Return the last reboot time of a computer #Usage: Get-LastBootUpTime [ServerName] Function Get-LastBootUpTime { param ([string]$computername=$env:computername) $computername = $computername.toupper() Get-WmiObject -ComputerName $computername win32_operatingsystem| select csname, @{LABEL=’LastBootUpTime’;EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}} } [/sourcecode]

  • Powershell Function to Get the Windows Version of a Computer

    [sourcecode language=”powershell” wraplines=”false”] #Get Windows version on a specific computer/instance #Usage: Get-WindowsVersion [ServerName] Function Get-WindowsVersion { param ([string]$computername=$env:computername) $computername = $computername.toupper() (Get-WmiObject -ComputerName $computername -Class Win32_OperatingSystem).Caption } [/sourcecode]

  • Powershell Function to Get Statues of All Sql Related Services

    [sourcecode language=”powershell” wraplines=”false”] #Get SQL-related services’ statuses on a specific computer #Usage: Get-SqlServiceStatus [ServerName] Function Get-SQLServiceStatus { param ([string]$ComputerName=$env:computername) Get-Service -ComputerName $ComputerName -Name "*sql*" } [/sourcecode]

  • Powershell Script of Sending an HTML Email Report in a Formatted Table

    This is a re-post from Powershell expert “Ben Wilkinson“, the original ps function is here. I did have some trouble in making it work in my own script and found that I have to add opening and closing “style” tags in the css definition part to make it work. So here I am writing a memo about…