by joe.pesch
26. March 2016 18:09
Add Windows Schedule and from the "Actions" tab, select "Start a program" dropdown and enter "powershell" (without the quotes) in the "Program/script:" text box then enter a command like the one below in the "arguments" text box:
-Command "Get-Date > c:\pathToLogFile.txt; $req = [System.Net.WebRequest]::Create(\"http://url\"); $res = $req.GetResponse(); $str = $res.GetResponseStream(); $rdr = new-object System.IO.StreamReader $str; $dat = $rdr.ReadToEnd(); $dat >> c:\pathToLogFile.txt; Get-Date >> c:\pathToLogFile.txt;"
Powershell HTTP Request
$r = [System.Net.WebRequest]::Create("http://url/")
$resp = $r.GetResponse()
$reqstream = $resp.GetResponseStream()
$sr = new-object System.IO.StreamReader $reqstream
$result = $sr.ReadToEnd()
write-host $result
Username and passwords
$creds = new-object System.Net.NetworkCredential "username", "password"
$uri = mew-object System.Uri "http://url/"
$credcache = new-object System.Net.CredentialCache
$credcache.Add($uri, "Basic", $creds)
$webrequestobject.Credentials = $credcache
One Liner Version
Powershell -Command "$r = [System.Net.WebRequest]::Create('http://url/'); $resp = $r.GetResponse(); $respstream = $resp.GetResponseStream(); $sr =
new-object System.IO.StreamReader $respstream; $result = $sr.ReadToEnd(); write
-host $result"
1cb12b3f-6e23-477c-bc47-fecc5f973a10|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags:
PowerShell
by joe.pesch
16. July 2012 17:02
We added an editable PDF document to our Sharepoint 2010 site; however, under the sites default settings it forced the user to save the document (i.e. it would not open the document directly from the site). Below is a PowerShell script that will add the PDF MIME type to the list of allowable inline download types. NOTE: Save the script with .PS1 extension to run in PowerShell.
$webapp = Get-SPWebApplication http://sharepointsitehere
If ($webapp.AllowedInlineDownloadedMimeTypes -notcontains "application/pdf")
{
Write-Host -ForegroundColor White "Adding Pdf MIME Type..."
$webapp.AllowedInlineDownloadedMimeTypes.Add("application/pdf")
$webapp.Update()
Write-Host -ForegroundColor White "Added and saved."
}
Else
{
Write-Host -ForegroundColor White "Pdf MIME type is already added."
}
6ed6cabc-497c-4b43-9609-6b4d2b1e2160|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags:
Sharepoint | PowerShell