Monday, August 15, 2016
C# - comparing version numbers
I wasted some time this morning writing my own version comparer, trying to write something short and smart that would be able to compare, if, for example,
version 4.56.7 is greater than version 4.3.2.1
turns out C# already has a lib for that :
https://msdn.microsoft.com/en-us/library/system.version.aspx
It can take up to 4 dot-separated components - major, minor, build, and revision.
version 4.56.7 is greater than version 4.3.2.1
turns out C# already has a lib for that :
https://msdn.microsoft.com/en-us/library/system.version.aspx
It can take up to 4 dot-separated components - major, minor, build, and revision.
Tuesday, August 9, 2016
SSRS Reporting Services - Site Settings security with PowerShell
Handy little PowerShell to automate adding a User or a Group to Site Settings of SSRS 2008 R2:
based on https://social.technet.microsoft.com/Forums/sqlserver/en-US/ea8824fb-e1c4-4266-9e73-ef00a6c0a6cd/site-settings-security-using-rss-scripts?forum=sqlreportingservices
$rs = New-WebServiceProxy -uri "http://server/reportserver/ReportService2010.asmx?WSDL" -UseDefaultCredential -namespace "ReportingService2010" -class Reporting
$existingpolicies = $rs.GetSystemPolicies()
$Policy = New-Object -TypeName "ReportingService2010.Policy"
$Roles = @()
$Role = New-Object -TypeName "ReportingService2010.Role"
$Role.Name = "System User"
$Roles += $Role
$Policy.Roles = $Roles
$Policy.GroupUserName = "DOMAIN\USERORGROUP"
$PolicyAlreadyExists = $false
$existingpolicies | Foreach-Object{
if ($_.GroupUserName -eq "DOMAIN\USERORGROUP")
{$PolicyAlreadyExists = $true} }
$Policies = @($existingpolicies)
$Policies += $Policy
if(-not $PolicyAlreadyExists)
{
$rs.SetSystemPolicies($Policies)
}
based on https://social.technet.microsoft.com/Forums/sqlserver/en-US/ea8824fb-e1c4-4266-9e73-ef00a6c0a6cd/site-settings-security-using-rss-scripts?forum=sqlreportingservices
Wednesday, July 13, 2016
Capturing output from external commands in PowerShell
Great article on running external commands from PowerShell:
http://edgylogic.com/blog/powershell-and-external-commands-done-right/
Especially useful - information on capturing output from external commands in PowerShell:
for example:
http://edgylogic.com/blog/powershell-and-external-commands-done-right/
Especially useful - information on capturing output from external commands in PowerShell:
for example:
& schtasks /END /TN $TaskName | Tee-Object -Variable scriptOutput | Out-Null
Write-Host $scriptOutput
Wednesday, June 29, 2016
Powershell: Copy files from Network location
Subscribe to:
Posts (Atom)