Document is locked for editing on a Sharepoint farm

Suddenly out of the blue we where confronted with document locking on our Sharepoint farm. Starting to have a look at the event log, and then the Sharepoint log files. mmmm Nothing wrong with that. Checking the SQL server belonging to the farm al log files clear.

I decided to put some search sentences using Google.

Well I found a lot of stuff about this problem, but all the solutions where pointing to the client site. That’s strange because till yesterday all was working well and no windows update is pushed to the clients.

Then a found a blog post about Implicit vs Explicit Document Check-out in Sharepoint from Ian. Reading this and actually looking at the screens. The modified date of the document that could be it. Because in the past, lets say the last time we used visual source save ;-) ye ye I know but its a long long time ago. I had a similar issue.

So I opened up the farm SQL server again and have a look at the system date/time. And yes there it is for a unknown reason de SQL server was running 1 hour behind the time of our AD. That’s very strange because of the time sync is managed by AD and al other machines are pointing to our domain server. I have to investigate this so it will not happen again.

So after setting the date/time to the same time as our AD. All the file locking problems are gone with the wind…

So keeping that in mind that its not your sharepoint server which is responsible for the date/time stamps on your documents, but its your SQL server.

Cheers

Slowly loading MS Word,Visio (and so on) documents from SharePoint.

I found after using the “google-o-matic” several possible solutions.
The right way to go? well check this out, the delay is caused by IE. Yes that’s right it has nothing to do with SharePoint.
So what to do.See the figure below:

image

Open IE and check the connections tab.
Choose LAN settings and check use proxy and check Bypass proxy and choose Advanced.
Put your localhost ip 127.0.0.1 and port number 80 in the boxes.
And check use the same proxy and don’t forget to fill in exceptions ” *.*

This can also be done by a group policy. Just start the GP editor

image

Cheers.

PowerShell Revert to snapshot

For our test environment we need to rollback to a snapshot(default) every evening. I don’t like to do that by hand so lets create a script.
The second point it has to be run as a scheduled task and I don’t want to parse my credentials within the script as plain text.

First of all
On the machine that has to run the task, create the credentials file:
From the PowerShell command run New-VICredentialStoreItem -host ‘vccenter’ -user ‘marcus’ -password ‘garvey’ -file c:\vc_cred

Getting the credentials:
$creds = Get-VICredentialStoreItem -file c:\vc_cred

so in code it will end up as:

###################################################################
#
# ReverseToSnapshot.ps1
#
# -Get stored credentials
# -Connect to vCenter
# -Shutdown Virtual machine
# -Set to required snapshot
# -Remove other snapshots
# -Start Virtual machine again
#
# Example:
# .\ReverseToSnapshot.ps1 -vmname TIIS01.domain.com -snapshotsname Do-Not-Remove-Default
# Version 1.0 juni 2010 JW Nieuwenhuizen ict.myjewe.nl
#
####################################################################

param(
    [parameter(Mandatory = $true)]
    [string]$vmname,
    [string]$snapshotsname
)

function PowerOff-VM{
    param([string] $vm)
        if((Get-VM $vm).powerstate -eq “PoweredOff”){
        Write-Host “$vm is already powered off”}
        else{
    Shutdown-VMGuest -VM (Get-VM $vm) -Confirm:$false | Out-Null
    Write-Host “Shutdown $vm”
    do {
        $status = (get-VM $vm).PowerState
    }until($status -eq “PoweredOff”)
    }
}

function PowerOn-VM{
    param( [string] $vm)
    if((Get-VM $vm).powerstate -eq “PoweredOn”){
        Write-Host “$vm is already powered on”}
    else{
        Start-VM -VM (Get-VM $vm) -Confirm:$false | Out-Null
        Write-Host “Starting $vm”
        do {
            $status = (Get-vm $vm | Get-View).Guest.ToolsRunningStatus
        }until($status -eq “guestToolsRunning”)
    }
}

function Remove-Snapshot-VM{
    param( [string] $vm, [string] $vm1)
    $snaps = Get-Snapshot -VM (Get-VM -Name $vm)
    foreach ($snappie in $snaps)
    {
        if ($snappie.Name -eq $vm1){
        Write-Host “This one we need again $vm1″}
        else{
        Get-Snapshot -VM (Get-VM -Name $vm) -Name $snappie.Name | Remove-Snapshot -Confirm:$false | Out-Null
        }
    }
}

#######################################################################################
# Main script
#######################################################################################
# Import VimAutomation.Core to run from a “normal” powershell prompt
add-pssnapin VMware.VimAutomation.Core

# Get and Decript credentials and Connect vcenter Using AD credentials
$creds = Get-VICredentialStoreItem -file c:\vc_cred
    foreach ($item in $creds){
    Connect-VIServer -Server $item.Host-User $item.User -Password $item.Password
}

$poweroff = PowerOff-VM $vmname

# Set Snapshot name
$snapname = Get-Snapshot -VM (Get-VM -Name $vmname) -Name $snapshotsname
# Set VM to snapshot
Set-VM -VM $vmname -Snapshot $snapname -confirm:$false

$removesnap = Remove-Snapshot-VM $vmname $snapshotsname
$poweron = PowerOn-VM $vmname

Disconnect-VIServer -Confirm:$False

Thanks to A Fokkema and baars.it and secure-credential-storage

Posted in Esx4 PowerShell VMWare by admin. No Comments