Browse by Tags
All Tags »
QuickTip (
RSS)
We had a Risk and Health Assessment Program (RAP) for SQL Server running in our environment in the last few days and one of the issues in the final report was: My PowerShell "wheels" started to roll and I suggested our team have a script to check for such inconsistences. So, here's how we can perform a quick check against a two node cluster (or any other pair of computers) using PowerShell and find if the installed hotfixes are not identical. First we use the Get-HotFix cmdlet to retrieve...
Take a look at the following two examples. Both commands gets a list of log files, selects a subset of each file properties and logs them to a file. Get-ChildItem -Filter *.log -Recurse | ForEach-Object { $_ | Select-Object Name,Length,FullName | Out-File -FilePath D:\LogFilesReport.txt -Append } Get-ChildItem -Filter *.log -Recurse | ForEach-Object { $_ | Select-Object Name,Length,FullName } | Out-File -FilePath D:\LogFilesReport.txt –Append At first glance both commands looks very similar but under...
The System.Uri class provides an object representation of a uniform resource identifier (URI) and easy access to the parts of the URI. One of its properties is IsUnc . IsUnc gets whether the specified Uri is a universal naming convention (UNC) path and returns a Boolean value that is True if the Uri is a UNC path or False otherwise. #Requires -Version 2.0 function Test-UNC { param( [Parameter(Mandatory=$true,Position=0,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] [Alias('FullName'...
Windows PowerShell provides access to the system registry via two PowerShell drives: HKLM and HKCU, which maps to the HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER registry hives respectively. PS > Get-PSDrive -PSProvider Registry Name Used (GB) Free (GB) Provider Root CurrentLocation ---- --------- --------- -------- ---- --------------- HKCU Registry HKEY_CURRENT_USER HKLM Registry HKEY_LOCAL_MACHINE To add registry drives for other hives like HKEY_USERS,HKEY_CLASSES_ROOT etc, we can use the New...
Here’s a quick way to find out. Pipe the file to the New-TimeSpan cmdlet. PS > Get-ChildItem foo.txt | New-TimeSpan Days : 319 Hours : 7 Minutes : 8 Seconds : 48 Milliseconds : 409 Ticks : 275873284097833 TotalDays : 319.29778252064 TotalHours : 7663.14678049536 TotalMinutes : 459788.806829722 TotalSeconds : 27587328.4097833 TotalMilliseconds : 27587328409.7833
With the following PowerShell one-liner you can check if the machine you’re working on has internet connectivity. The result is a Boolean value. If TRUE, the local machine is connected to the internet; if FALSE, it is not. Minimum supported client : Windows Vista [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet