Skip to main content

Posts

Showing posts from February, 2013

Testing Connection String with PowerShell

To test a connection string (in my case with MultisubnetFailover parameter) I used this simple PowerShell script: $ConStr=' Server=SQLdevCluster1;Database=TESTDB1;Trusted_Connection=yes;Provider=SQLNCLI11;MultisubnetFailover=TRUE ' $conn = New-Object System.Data.OleDb.OleDbConnection $conn.ConnectionString = $ConStr $conn.Open() $Tables = $Conn.GetOleDbSchemaTable([System.Data.OleDb.OleDbSchemaGuid]::tables,$null)  $Tables | FT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE,DATE_CREATED | More $conn.Close() The server must have SQL 2012 native client installed and the account you use to run this script must have permissions to connect to the SQL server (SQLDEVCluster1) and access the database (TESTDB1)

PowerShell scripts to upload/download files to/from SharePoint 2010 Library

to download all files from a SharePoint library Function Get-FilesFromSPSLibrary { Param ( [string] $FolderPath, [string] $SiteURL, [string] $ListTitle ) if (-NOT (Test-Path $FolderPath -PathType 'Container'))  {            write-host "`n[$($FolderPath)] is not a valid folder or you have no access to it`n`n"  return         } [net.httpWebRequest] $req = [net.webRequest]::create($SiteURL) $req.Method = "HEAD" $Req.UseDefaultCredentials = $true; try { [net.httpWebResponse] $res = $req.getResponse() } Catch {   write-host "`nSite [$SiteURL] is inaccessible`n" return } $MySite = Get-SPWeb -Identity $SiteURL $Mylist = $MySite.Lists[$ListTitle]  if ($Mylist -eq $null)  {  write-host "Unable to open list [$ListTitle] at [$SiteURL]" return }  ForEach ($Fl in $MyList.Items) { $fname=$Folderpath+$fl.Name write-host "Downloading [$($Fl.url)] ..." $binary=$My

Recursive Report to Traverse Time Hierarchy

I need to create a report that allows end-users to select multiple items from the Date hierarchy (e.g., Year-2007, Q4-Year-2006, November-2007) and then the report should show a chart and a table with measures for the selected periods like this one (using the Adventure Works cube from SQL 2012) And the next requirement is to allow users to click on the date in the table (e.g., Q4 CY 2006) and the reports will show the same information but for all direct children of the selected time period  (e.g., Oct 2006, Nov 2006, Dec 2006) like this one: And if a user clicks on the month it will get the report for all dates in the selected month. I started with Query designer and placed "Internet Sales Amount", Category (from the Product dimension) , and the Date.Calendar hierarchy. I also add the Date.Calendar hierarchy to the parameters panel. When I changed the design mode the MDX script generated by the Query Designer is this (slightly reformatted) SELECT  NON EM