SharePoint Slideshow

  1. Param
  2.     $DocLibSite = "http://MyMOSS/Reports",     # SHAREPOINT Document Library site 
  3.     $DocLibName  = "Daily"                    # SHAREPOINT Document Library Name 
  4.  
  5. #REGION EXCEL FUNCTIONS 
  6. function Invoke([object]$m, [string]$method, $parameters
  7. $m.PSBase.GetType().InvokeMember
  8. $method, [Reflection.BindingFlags]::InvokeMethod, $null, $m, $parameters
  9. $ciUS
  10.  
  11. Function RefreshExcel {  
  12. Param ( $xls
  13. #Only XL* files 
  14. if ($xls.split(".")[-1] -match "xl*") { 
  15.     # US culture 
  16.     $ciUS = [System.Globalization.CultureInfo]'en-US' 
  17.     $Excel = New-Object -ComObject excel.application 
  18.     $thisThread = [System.Threading.Thread]::CurrentThread 
  19.     $originalCulture = $thisThread.CurrentCulture 
  20.     $thisThread.CurrentCulture = New-Object System.Globalization.CultureInfo("en-US"
  21.  
  22.     $Excel.Visible = $false 
  23.     $Excel.Displayalerts=$false 
  24.  
  25.     $Books = $Excel.Workbooks 
  26.     Write-Progress -Activity "Open file" -status "f:" -PercentComplete 10 -CurrentOperation $xls 
  27.     Try { 
  28.         $ExcelWB = Invoke $Books open($xls); 
  29.     } catch {Write-Host "Open:$_"; $Excel.quit() | Out-Null;Return $false
  30.         Write-Progress -Activity "Run Macro" -status "f:" -PercentComplete 40 -CurrentOperation $xls 
  31.     #Run Refresh Macro 
  32.     Try { 
  33.         $Excel.Application.Run("Refresh"); 
  34.     } catch {Write-Host "Run:$_"; $Excel.quit() | Out-Null;Return $false
  35.         Write-Progress -Activity "Save file" -status "f:" -PercentComplete 60 -CurrentOperation $xls 
  36.     Try { 
  37.         invoke $ExcelWB Save| Out-Null 
  38.     } catch {Write-Host "Save:$_"; $Excel.quit() | Out-Null;Return $false
  39.         invoke $ExcelWB Close | Out-Null 
  40.      
  41.     $Excel.quit() | Out-Null 
  42.     $thisThread.CurrentCulture = $originalCulture 
  43.     Return $true 
  44. } else {} 
  45.  
  46. #REGION SHP 
  47. Function Get-SHPDocList { Param ($site,$listName,$rowLimit = "100"
  48.     $uri = $site + "/_vti_bin/lists.asmx?WSDL"     
  49.     # Create the service             
  50.     try{             
  51.         $service = New-WebServiceProxy -Uri $uri  -Namespace SpWs  -UseDefaultCredential               
  52.     }             
  53.     catch{              
  54.         Write-Error $_ -ErrorAction:'SilentlyContinue'              
  55.     
  56.     # Create xml query to retrieve list.              
  57.     $xmlDoc = new-object System.Xml.XmlDocument             
  58.     $query = $xmlDoc.CreateElement("Query")             
  59.     $viewFields = $xmlDoc.CreateElement("ViewFields")             
  60.     $queryOptions = $xmlDoc.CreateElement("QueryOptions")             
  61.     $query.set_InnerXml("FieldRef Name='ID'")              
  62.      
  63.     $list = $null              
  64.     if($service -ne $null){             
  65.         try{      
  66.             $list = $service.GetListItems($listName, "", $query, $viewFields, $rowLimit, $queryOptions, ""
  67.         }             
  68.         catch{              
  69.             Write-Error $_ -ErrorAction:'SilentlyContinue'             
  70.         }             
  71.     
  72.     if ($list) { 
  73.         $list.data.row | % {$_.ows_EncodedAbsUrl
  74.     
  75. #ENDREGION SHP 
  76. #ENDREGION EXCEL FUNCTIONS 
  77.  
  78. Get-SHPDocList $DocLibSite $DocLibName 1000 | %
  79.     if ($_) { 
  80.         Write-Host "Refreshing ... $_" 
  81.         if (RefreshExcel $_) {Write-host "    SUCCESS Refresh on $_"} else {"    FAILED Refresh on $_"
  82.     
 
Loading...
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.