Install NuGet via PowerShell script
Run Powershell with Admin rights Type the below PowerShell security protocol command for TLS12: [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Run Powershell with Admin rights Type the below PowerShell security protocol command for TLS12: [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Use the $progressPreference variable. It should have a value of ‘Continue’ by default unless you’ve edited it elsewhere, which tells Powershell to display the progress bar. Since you mentioned that you have your own custom progress displays, I would reset it immediately after the cmdlet is executed. For example: $ProgressPreference=”SilentlyContinue” # Subsequent calls do not … Read more
$json = @” { “Stuffs”: [ { “Name”: “Darts”, “Type”: “Fun Stuff” }, { “Name”: “Clean Toilet”, “Type”: “Boring Stuff” } ] } “@ $x = $json | ConvertFrom-Json $x.Stuffs[0] # access to Darts $x.Stuffs[1] # access to Clean Toilet $darts = $x.Stuffs | where { $_.Name -eq “Darts” } #Darts
Download and install from http://www.microsoft.com/en-us/download/details.aspx?id=34595. You need Windows 7 SP1 though. It’s worth keeping in mind that PowerShell 3 on Windows 7 does not have all the cmdlets as PowerShell 3 on Windows 8. So you may still encounter cmdlets that are not present on your system.
Like this? [bool]($myObject.PSobject.Properties.name -match “myPropertyNameToTest”)
Just to offer the alternative to the Test-Path cmdlet (since nobody mentioned it): [System.IO.File]::Exists($path) Does (almost) the same thing as Test-Path $path -PathType Leaf except no support for wildcard characters
LoadWithPartialName has been deprecated. The recommended solution for PowerShell V3 is to use the Add-Type cmdlet e.g.: Add-Type -Path ‘C:\Program Files\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.SqlServer.Smo.dll’ There are multiple different versions and you may want to pick a particular version. 🙂
The given answers will only delete files (which admittedly is what is in the title of this post), but here’s some code that will first delete all of the files older than 15 days, and then recursively delete any empty directories that may have been left behind. My code also uses the -Force option to … Read more