Showing posts with label PowerShell. Show all posts
Showing posts with label PowerShell. Show all posts

Tuesday, January 13, 2015

Change recovery model to Simple for all databases

Import-Module SQLServer
Get-SqlDatabase -sqlserver . | ? {$_.RecoveryModel -eq [Microsoft.SqlServer.Management.Smo.RecoveryModel]::Full } | % { $_.RecoveryModel = [Microsoft.SqlServer.Management.Smo.RecoveryModel]::Simple ; $_.Alter() }

Thursday, January 16, 2014

Yet another reason to use PowerShell

From this article:

Notice that all XML nodes in the document are converted to standard PowerShell properties, whether a node has children (e.g. catalog) or is a leaf node (e.g. price), or whether a leaf node is an element (e.g. author) or an attribute (e.g. id). In particular (as the last two examples above illustrate), element values and attribute values are treated exactly the same with standard “dot” notation.

This sill also help us suck work with DataSets, converting them to XML and then accessing the data as properties.

Thursday, June 07, 2012

Wednesday, January 11, 2012

My Powershell Profile

I updated my profile in .\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 to include SharePoint:

function prompt {
$Host.UI.RawUI.WindowTitle=$(get-location)
"$ ";
}

#Set environment variables for Visual Studio Command Prompt
pushd 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC'
cmd /c "vcvarsall.bat&set" |
foreach {
if ($_ -match "=") {
$v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
}
}
popd
write-host "`nVisual Studio 2010 Command Prompt variables set." -ForegroundColor Yellow

& ' C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\sharepoint.ps1'
write-host "`nSharePoint environment set." -ForegroundColor Yellow

Wednesday, August 11, 2010

Visual Studio command prompt with Powershell

I updated my profile in .\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 to include VS2010 prompt:


function prompt {
$Host.UI.RawUI.WindowTitle=$(get-location)
"$ ";
}

#Set environment variables for Visual Studio Command Prompt
pushd 'c:\Program Files\Microsoft Visual Studio 10.0\VC'
cmd /c "vcvarsall.bat&set" |
foreach {
if ($_ -match "=") {
$v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
}
}
popd
write-host "`nVisual Studio 2010 Command Prompt variables set." -ForegroundColor Yellow

Wednesday, August 04, 2010

Comma in Powershell

Mmm Learned today the hard way that comma should not be used to separate parameters. That is, instead of:
Encrypt-String "Alex", "089234kljhwsdf=", "98qasdlfkjhasdflkjh==
you should use
Encrypt-String "Alex" "089234kljhwsdf=" "98qasdlfkjhasdflkjh==

Great explanation here.

Wednesday, July 28, 2010

Generate encryption key (128-bit) for RijndaelManaged

$algorithm = [System.Security.Cryptography.SymmetricAlgorithm]::Create("Rijndael")
$algorithm.set_keysize(128)
$keybytes = $algorithm.get_Key()
$ivbytes = $algorithm.get_IV()
[System.Convert]::ToBase64String($keybytes)
[System.Convert]::ToBase64String($ivbytes)

Wednesday, July 21, 2010

My profile

Create folder WindowsPowerShell in My Documents
Create file Microsoft.PowerShell_profile.ps1
Copy this into the file:

function prompt {
$Host.UI.RawUI.WindowTitle=$(get-location)
"$ ";
}

Powershell command to get all the groups I belong to.

$ [Security.Principal.WindowsIdentity]::GetCurrent().Groups | % {$_.Translate([Security.Principal.NTAccount]) }

Thursday, September 27, 2007