Recently we have moved our web application from one server to another in Sharepoint 2010. Back up of entire web application was taken and restored in another server. But in the new server , the PDF files in the document library is not getting opened in browser. it always open in browser
I have already made following changes but didn,t work
Set browser file handling to Permissive from central admin
Set "open in browser" in setting s of doc library
Set the doc library file handling property using
$docLib = $web.lists["Your Document Library Title"]
$docLib.BrowserFileHandling = "Permissive"
$docLib.Update()
Added "AllowedInlineDownloadedMimeType.Add("Application/Pdf") in web app
Installed Adober eader in client machine
Even after trying all these, the PDF files are still opening in Client application(Adobe reader) but not in the browser
It would have been great help if anybody provide a solution for this. I have been banging head on this for two days
Regards
Vishnu
You need to add the MIME type to SharePoint 2010 to enable this - and it needs to be done at Farm level.
The powershell on here will do it; (I've not run it, but it is Technet so source should be good)
# <#
# .DESCRIPTION
#
# This script adds new MIME type to "AllowedInlineDownloadedMimeTypes" property list of defined SharePoint 2010 Web Application.
#
# Script prompts you for MIME type and Web Application URL.
#
# Code shall run in context of Farm Administrators group member.
#
# .NOTES
# File Name : Add_MIME_Type.ps1
# Author : Kamil Jurik, WBI Systems a.s.
# Created : 11/12/2011
#
If ( (Get-PSSnapin -Name "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null ) {
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
Get-SPWebApplication
$WebApp = Get-SPWebApplication $(Read-Host "`nEnter Web Application URL")
Write-Host `n"Mime Type Examples:"`n"application/pdf, text/html, text/xml"`n
If ($WebApp.AllowedInlineDownloadedMimeTypes -notcontains ($MimeType = Read-Host "Enter a required mime type"))
{
Write-Host -ForegroundColor White `n"Adding" $MimeType "MIME Type to defined Web Application"$WebApp.url
$WebApp.AllowedInlineDownloadedMimeTypes.Add($MimeType)
$WebApp.Update()
Write-Host -ForegroundColor Green `n"The" $MimeType "MIME type has been successfully added."
} Else {
Write-Host -ForegroundColor Red `n"The" $MimeType "MIME type has already been added."
}
You can set the Browse file handling property to permissive
http://technet.microsoft.com/en-us/library/cc262107(v=office.14).aspx
Related
I want to edit a link on the left side of a SharePoint 2013 Standard site. Clicking on Edit Links and changing the link to a desired site and then saving shows error "This operation has timed out. Please try again." and clicking on Quick launch keeps spinning. I have full access to the site.
What could be the cause ?
did You consider using PowerShell as a workaround solution? If something in SharePoint that is OOB and does not work I always consider PS to fix something :).
For Your case something like this may do the trick (example to delete and update):
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
{
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
$SPWeb = Get-SPWeb "[URL]";
$QuickLaunch = $SPWeb.Navigation.QuickLaunch;
foreach($item in $QuickLaunch)
{
$item.Title;
if($item.Title -eq '[quickLunchItemTitleToDelete]')
{
$SPWeb.Navigation.GetNodeById($item.Id).Delete();
}
if($item.Title -eq '[quickLunchItemTitleToModify]')
{
$item.Title = "[NewName]";
$item.Update();
}
}
also I saw You have in site settings link to Quick Lunch. But You may turn on a feature in web to get the more advanced 'Navigation' link and maybe from there You will be able to modify the link You need.
Go to Site settings > Under Site collection admin > Site collection
features
Click Activate in-front of SharePoint Server Publishing
Infrastructure
BUT please be aware that turning on this feature will add also other components to Your which may be not desired.
I hope this will be of any help to You :)
I've been working on a PowerShell script, with the intent of refreshing a excel document's SQL data daily via task scheduler. The excel document is hosted on SharePoint. I've (after much, much trial and error) gotten it to work up until the checkin part.
Basically, Task Scheduler fires the PowerShell script daily.
The script creates an excel COM object.
It verifies it can checkout the document, then does so if able.
It then performs the refresh.
Finally, it attempts to checkin the document. At this point, it just
hands and nothing happens. I should note this ONLY happens when the
script is run via task scheduler, and 'whether user is logged in or
not' is selected. If run from the PowerShell cmd line or the
option 'user must be logged in' is checked, everything performs
fine.
Couple important notes-
The account is a service account user, although we granted it local login during testing. It has GOT to be unattended in practice though.
I followed the instructions for folders on this page-
https://social.technet.microsoft.com/Forums/en-US/aede572b-4c1f-4729-bc9d-899fed5fad02/run-powershell-script-as-scheduled-task-that-uses-excel-com-object?forum=winserverpowershell
It is worth noting I also had to set permissions on the folders mentioned a few posts past the initial comment. I STRONGLY suspect my current issue is similar/related- but it must not be these folders because I have pretty open permissions here.
I had to remove 'enhanced IE security' as this is a server box and PowerShell couldn't initially 'see' the SharePoint site.
I've checked the event log- the office log is apparently operational, but there is no popup at the time of checkin apparently.
I've set and verified COM permission settings, although it is possible I missed something here. Excel wasn't listed in the APP list but adding the user to the call privileges moved me forward on the task.
I'm pretty sure this doesn't happen if I run it as a dev administrator.
CYA-
I'm aware MS doesn't endorse the above, but I'm also aware people get it to work.
Powerpivot for SharePoint is not really an option at this time.
This is like my third question ever (I normally bang my head against the wall until I get it, but I'm getting a bit bloody here for 'just' a PowerShell script. Please bear with me if I'm over/under wordy :)
Truncated script below- (removed try/catch and debug messages. If you want the cleaned full let me know, I'd love to save someone the trouble I had.)
$i = "http://supersecretintranetsite/excelwithsqldatacon.xlsx"
# Creating the excel COM Object
$Excel = New-Object -ComObject Excel.Application;
Start-Sleep -s 5
# Setting up Excel to run without UI and without alerts
$Excel.DisplayAlerts = $false
$Excel.ScreenUpdating = $false
$Excel.Visible = $false
$Excel.UserControl = $false
$Excel.Interactive = $false
If ($Excel.workbooks.CanCheckOut($i))
{
# Opening the workbook, can be local path or SharePoint URL
$Workbook = $Excel.workbooks.Open($i);
# Perform the check out
$Workbook = $Excel.workbooks.CheckOut($i)
$Workbook = $Excel.workbooks.Open($i);
Start-Sleep -s 15
# Calling the refresh
$Workbook.RefreshAll();
# Forces a hold until all Refreshing is done
$Excel.CalculateUntilAsyncQueriesDone()
# Saving and closing the workbook
# $Workbook.Save() #- this hangs too
Start-Sleep -s 15
# THIS HANGS
$Workbook.CheckInWithVersion();
Start-Sleep -sec 5
#Release Workbook
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($Workbook)
}
$Excel.quit();
Turned out to be more folder permissions.
I added full control permissions for that user to the Appdata folder in the \windows*\config\systemprofile folders and it worked.
I'd assigned read/write but I guess that wasn't enough.
I have a requirement where I need to enter secure Id from RSA token during login authentication and then start running automation test.
Is it possible to access the RSA token value programmatically through any api or any other way , so that test flow can be automated completely?
We automated our login to a vpn that uses rsa secure id and Cisco AnyConnect, by doing the following:
1) Open rsa secure id programatically the way you want
2) Run the following .ps1
#Source http://www.lazywinadmin.com/2010/06/powershell-get-clipboard-set-clipboard.html
function Get-ClipBoard {
Add-Type -AssemblyName System.Windows.Forms
$tb = New-Object System.Windows.Forms.TextBox
$tb.Multiline = $true
$tb.Paste()
$tb.Text
}
# end Source http://www.lazywinadmin.com/2010/06/powershell-get-clipboard-set-clipboard.html
$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate('the name')#Here you need to write the name that appears on the left top corner of the rsa secure id window
Sleep 1
$wshell.SendKeys('{TAB}')
$wshell.SendKeys('~')
$a = Get-ClipBoard
#Source http://www.cze.cz
#This script is tested with "Cisco AnyConnect Secure Mobility Client version 3.0.5080″
#Please change following variables
[string]$CiscoVPNHost = 'the vpn you are trying to connect'
[string]$Login = 'your user'
[string]$Password = $a
#Please check if file exists on following paths
[string]$vpncliAbsolutePath = 'C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpncli.exe'
[string]$vpnuiAbsolutePath = 'C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe'
#****************************************************************************
#**** Please do not modify code below unless you know what you are doing ****
#****************************************************************************
Add-Type -AssemblyName System.Windows.Forms -ErrorAction Stop
#Set foreground window function
#This function is called in VPNConnect
Add-Type #'
using System;
using System.Runtime.InteropServices;
public class Win {
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
}
'# -ErrorAction Stop
#quickly start VPN
#This function is called later in the code
Function VPNConnect()
{
Start-Process -FilePath $vpncliAbsolutePath -ArgumentList "connect $CiscoVPNHost"
$counter = 0; $h = 0;
while($counter++ -lt 1000 -and $h -eq 0)
{
sleep -m 10
$h = (Get-Process vpncli).MainWindowHandle
}
#if it takes more than 10 seconds then display message
if($h -eq 0){echo "Could not start VPNUI it takes too long."}
else{[void] [Win]::SetForegroundWindow($h)}
}
#Terminate all vpnui processes.
Get-Process | ForEach-Object {if($_.ProcessName.ToLower() -eq "vpnui")
{$Id = $_.Id; Stop-Process $Id; echo "Process vpnui with id: $Id was stopped"}}
#Terminate all vpncli processes.
Get-Process | ForEach-Object {if($_.ProcessName.ToLower() -eq "vpncli")
{$Id = $_.Id; Stop-Process $Id; echo "Process vpncli with id: $Id was stopped"}}
#Disconnect from VPN
echo "Trying to terminate remaining vpn connections"
start-Process -FilePath $vpncliAbsolutePath -ArgumentList 'disconnect' -wait
#Connect to VPN
echo "Connecting to VPN address '$CiscoVPNHost' as user '$Login'."
VPNConnect
#Write login and password
[System.Windows.Forms.SendKeys]::SendWait("$Login{Enter}")
[System.Windows.Forms.SendKeys]::SendWait("$Password{Enter}")
#Start vpnui
start-Process -FilePath $vpnuiAbsolutePath
#Wait for keydown
#echo "Press any key to continue …"
#try{$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")}catch{}
#Exit
All you need to do now is to set your vpn, and user on the script above.
You need to specify what kind of token you use.
There are number of choices here I heard of:
hardware token
software token application (Mac OS, Windows, iOS, Android, Windows Mobile, and few others)
web browser token
Please check this link for more details:
http://www.emc.com/security/rsa-securid/rsa-securid-software-authenticators.htm#!offerings_for_web_browsers
With hardware token you will need to use some kind of camera and read pixels of the image taken (I will not be able to help you there)
Software token is simpler.
I have recently created small command line tool that is able to execute, enter PIN, and read Passcode generated in the token application.
I cannot send you the tool (property of my company), but I can give you some tips what you need to do to create your own application that will do the same stuff.
But first you need to tell me whether you use software token or not.
OK.
Since you have software token I'll describe what my app do to automatically connect to VPN.
1) you need to have your software token configured prior doing this.
On top of that VPN client will need to be also configured, and connection must be listed on available connection list.
When it is configured you can do your auto VPN Connection.
We have software token similar to this one:
https://ssl.seagate.com/ssl/docs/soft_token_install_instructions.html
Our VPN Client looks looks something like this one:
http://wireless-setup.wsu.edu/msIPSEC.html
2) Once all tools are configured you can start your VPN connection.
You need to be prepared to do deep investigation.
Guys from RSA worked really hard to make it impossible this what we are doing here.
They don't use ordinary controls. They have created their own controls I do not have
spec for.
I have done it using C++ and WIN32 API functions. This is my recipe.
a) read parameters passed to the program
b) validate the parameters
I have number of params like PIN, connection number to establish, Command to run when connection is established etc. They can be hardcoded of course but to be flexible I can pass them from command line.
c) check for token application [EnumWindows]
Token app can have 2 top level windows [The one you enter PIN, and the one with passcode]
If I detect both windows opened I close the app and restart it.
You can try sending Message WM_CLOSE to close the app. I simulate users action to press "X" close button
//restore it <if minimized>
SendMessage(hwndTokenApplicationPinWindow,WM_SYSCOMMAND,SC_RESTORE,NULL);
//close the app
SendMessage(hwndTokenApplicationPinWindow,WM_LBUTTONDOWN,MK_LBUTTON,MAKELPARAM(223,14));
SendMessage(hwndTokenApplicationPinWindow, WM_LBUTTONUP,0,MAKELPARAM(223,14));
To start it I use CreateProcess function.
When you restart the app or you had only one window opened, you can now enter PIN.
d) Enter PIN
I simulate users left click on pin window WM_LBUTTONDOWN, WM_LBUTTONUP.
I enter the pin using WM_CHAR.
Once entered, click OK button using WM_LBUTTONDOWN, WM_LBUTTONUP.
Once completed you should have Passcode window displayed.
e) Read passcode
To get the passcode I use Copy button from the token. This button Copy data to clipboard.
We simulate pressing this button: WM_LBUTTONDOWN, WM_LBUTTONUP
And read data from clipboard:
BOOL InvalidData = FALSE;
OpenClipboard(NULL);
HANDLE clip0 = GetClipboardData(CF_UNICODETEXT);
wchar_t* p=(wchar_t*)GlobalLock(clip0);
if(wcslen(p) == MaxPasscodeSize-1)
wcscpy_s(currentPasscode,MaxPasscodeSize,p);
else if(wcslen(p) != MaxPasscodeSize-1 && wcslen(p) != 0)
{
wprintf(L"Error: Passcode in clipboard is invalid\n");
InvalidData = TRUE;
}
GlobalUnlock(clip0);
CloseClipboard();
Now you have Passcode ready to be used in the CISCO VPN Client.
Please let me know if it make any sense to you.
If it does, and you your app works up to this point please let me know and I'll pass instruction to deal with VPN client.
If you need more detailed instruction for the steps above please let me know.
One idea is to record a bunch of clock/token pairs and run the clock back for your program and replay the recording. Actually, if you have the option of cooking the clock, you really only need one pair.
(I did not say it was a GOOD idea.)
Good luck,
/Bob Bryan
I have 100 web servers and noticed that some of them have request filtering enabled for ".exe" extension. This means that if a user wants to access a .exe file with an application we ave it is blocked by the server.
Is there a way of doing any type of command line or script whereby I know which servers are affected? Currently I am testing by doing a manual check by going to internet explorer and typing in:
http://***SERVER1***/website/OFFICEPRO/2007/Office%20Professional/setup.exe
http://***SERVER2***/website/OFFICEPRO/2007/Office%20Professional/setup.exe
If I get a pop-up box stating to enter my credentials then that works. Hwoever if I get "Error Page (404)" then that does not work.
Thanks,
You can use powershell to do this, the following should get you on your way:
$webClient = new-object Net.WebClient
gc servers.txt | Foreach-Object {
# send credentials to server
$webClient.UseDefaultCredentials = $true;
$url = "http://$_/website/OFFICEPRO/2007/Office%20Professional/setup.exe"
try
{
$reult = $webClient.DownloadString($url)
Write-host -fore Green $url "OK"
}
catch [System.Net.WebException]
{
Write-host -fore Red $url $_
}
}
The file named servers.txt contains the list of servers you want to check.
A user who created various lists in SharePoint Server 2010 has subsequently been deleted from the site collection. This leaves the user id in the SPList.Author property but results in "User cannot be found" messages in various places that try to instantiate the SPUser object.
Is there any supported way to update the SPList.Author property? I have tried with the server OM, Client OM and lists.asmx web service and have failed with all three.
I've never done it before, but using this guide here, here is what you could try on Powershell:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$siteUrl = "your sharepoint site url"
$webName = "your webname"
$spSite = new-object Microsoft.SharePoint.SPSite($siteurl)
$spWeb = $spSite.OpenWeb($webName)
$listName = "your listname"
$userLoginName = "your username"
$spList = $spWeb.Lists[$listName]
$spList.Author = $spWeb.AllUsers[$userLoginName]
$spList.Update() // I don't know if this is required.
maybe find a way to remove the user from the sitecollection
I have accepted that it is not possible to update SPList.Author, but my need to do so has also weakened.
The reason I wanted to do this was the encountering of "user cannot be found" errors on the list settings and workflow settings pages. I thought that it may have been originating in the list - because tools like SharePoint manager show "user cannot be found" when I examine the list author property.
It turned out, however, to be coming from workflow templates, not lists, that had been published by the since-removed user.