Massive upload files to SharePoint servers

I have been looking to make using some sort of script the way to make massive upload to a sharePoint server;
I have been finding many using Powershell and I came up with this type of script

param ([String]$spPath, [String]$localPath)

#################################################################################

## Load the SharePoint Snapin so the script can be executed from PowerShell editor
## INTERACTIVE OR AUTOMATIC MODE.

## FOR AUTOMATIC MODE. SET THE VARIABLE BELOW.OTHERWISE PROMPT WOULD REQUEST EACH.

## SET THE NUMBER OF TIME YOU WISH UPLOAD FOR EACH FILES
##$t = "10"

### SET THE REMOTE SHAREPOINT REMOTE LOCATION FOR THE SHARED DOCUMENT
### OR LET THE PROMPT
### EX: $spPath = "http://sharepoint/home/Shared%20Documents/"


#### SET LOCAL PATH OF FILES TO BE UPLOADED.
#### EX: $localPath = "e:\my_files"



##################################################################################


Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
# get the SharePoint path if not specified

$i = 1

if ($spPath -eq "")
{
    Write-Host
	$spPath = Read-Host -Prompt " Please enter the full path for the shared librairy?"
}

if ($t -eq "")
{
    Write-Host
	$t = Read-Host -Prompt " How Many times you wish to upload?"
}

# get the local path if not specified
if ($localPath -eq "")
{
    Write-Host
    $localPath = Read-Host -Prompt " Please enter the full path to the local directory that contains the documents to be uploaded"
}



do {Write-Host $i;$i++

## Define our library name and web url

$LibraryName = $spPath.Substring($spPath.LastIndexOf("/")+1)
$webUrl = $spPath.Substring(0,$spPath.LastIndexOf("/"))

## Define a function to return the destination file name

Function BuildFileName($filename)
{
    "$webUrl/$LibraryName/" + $(split-path -leaf $filename)
}
## Upload all the documents found in the specified location

Write-Host "Uploading all documents from $sourceDocs"
$webClient = New-Object System.Net.WebClient
$webClient.Credentials = [System.Net.CredentialCache]::DefaultCredentials
dir $localPath | % {
    Write-Host "Uploading file from "$localPath": $_" -nonewline
    $fName = BuildFileName $_
    $webClient.UploadFile($fName,"PUT", $_.FullName)
    Write-Host " done" -ForegroundColor Green
    }

}
until ($i -gt $t)

Query the windows registry

I had the need to query the registry for a specific string, if the string is found or not then engage an action.

Within this scenario as example, it query the registry and a specified string, an action is taken if this one is not found/present.

 

@ECHO OFF
set regpath=HKLM\Software\Microsoft\xx\
set regvalue=mystring
set regdata=1
reg query "%regpath%" /v "%regvalue%" | find /i "%regdata%"
if errorlevel 1 (
      echo Please wait blah blah......
      Start /WAIT .\myprog\install.exe
      EXIT /B /0
)

 

PHP Warning: phpinfo(): It is not safe to rely on the system’s timezone settings.

Having set the PHP Engine running on Domino Server; Any/All request to access to some PHP files filling up my log.nsf of this type of entries and warning:

PHP Warning:  phpinfo(): It is not safe to rely on the system's 
timezone settings. You are *required* to use the date.timezone 
setting or the date_default_timezone_set() function. 
In case you used any of those methods and you are still 
getting this warning, you most likely misspelled the timezone 
identifier. We selected the timezone 'UTC' for now, 
but please set date.timezone to select your timezone. 
in E:\IBM\Lotus\Domino\data\domino\html\info.php on line 4

One more thing is needed to be set into the php.ini file:

Set this line:

date.timezone = "UTC"

Or and based on your location; including the list of Supported Timezones

http://pl.php.net/manual/en/timezones.php

Domino server running PHP CGI /Install/implement PHP on Domino Windows Server

I have been looking the trick to run PHP engine into a Domino server;

By default, Domino Server does not support PHP; However I am including the step by step instructions on how to implement it into Domino Server on Windows Machine.

You need first the PHP binaries:

http://windows.php.net/download/

I have been using the version (5.4.9), downloadable here.

– Uncompress the content of this zip file.

Continue reading “Domino server running PHP CGI /Install/implement PHP on Domino Windows Server”

Customize Windows 7 splash

I found a nice tool that allow you to change or replace the traditional Windows screen at the boot.

This tool is called Win7BootUpdater.exe.

Also included a quick splash made for my home media center.

 

Unable to create a temp copy of transform

Attempting to upgrade Windows installer Application ‘s packages.
the MST failed, noticed the following error from the MSI log:

Installation: Unable to create a temp copy of transform,
Note: 1: 2203 2:  3: -2147287037
etc..
MainEngineThread is returning 1624

 

Solution that worked for me:

Change TRANSFORMSSECURE value to 0 in the registry, and try a re-installation

More details from MS:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa372089%28v=vs.85%29.aspx

sqmapi.dll corrupted on Windows 7

Had a recent issue on Win7, could not install the service pack 1 due to this dll which was missing.

I used the sfc /scannow at least 3 times and finally this dll has been restored; Unfortunately all the originals files from the system were also restored.

Having on this machine customized the Welcome message and some others….however I have been able to apply the sp.

vbs to mount windows shares

Function mapdrive()
‘ —— SCRIPT CONFIGURATION ——
strDrive = WScript.Arguments(0) ‘ e.g. i:
strPath = WScript.Arguments(1)
strUser = WScript.Arguments(2) ‘ e.g. Administrator
strPassword = WScript.Arguments(3)
boolPersistent = True ‘ True = Persistent ; False = Not Persistent
‘ —— END CONFIGURATION ———

set objNetwork = WScript.CreateObject(“WScript.Network”)
Set ObjFSO = CreateObject(“Scripting.FileSystemObject”)

‘Check and disconnect if the drive is already mapped.
if(ObjFSO.DriveExists(strDrive)) then
objNetwork.RemoveNetworkDrive strDrive, True, True
end if

objNetwork.MapNetworkDrive strDrive, strPath, boolPersistent, _
strUser, strPassword
if(ObjFSO.DriveExists(strDrive)) then
WScript.Echo “Successfully mapped drive : ” & strDrive & ” to ” & strPath
end if

Set ObjFSO = nothing
Set objNetwork = nothing
end function

Function parseArgs()
Dim filelen
filelen = WScript.Arguments.length
if filelen < 4 Then
WScript.Echo(“Usage : cscript //nologo mapdrive.vbs “)
WScript.Echo(“Example : cscript //nologo mapdrive.vbs i: \\myserver\data\myshare administrator mypassword”)
WScript.Quit()
end if
mapdrive()
End function

parseArgs()

then this type of command line:

cscript //nologo mapdrive.vbs i: \\myserver\data\myshare