Category Archives: PowerShell

How to Upload files to a SharePoint Document Library using PowerShell Script

# create the Variable Path and Pass the source folder path

$path = “D:\Source File\”;

# create the Variable destination and pass the URL of the SharePoint List

$destination = “http://projectserver14:99/PWA/SharePointListURL/“;

# Store the current user default credentials in the Variable Credentials

$credentials = [System.Net.CredentialCache]::DefaultCredentials;

# Create the object of the Webclient

$webclient = New-Object System.Net.WebClient;

# Pass the user credentials

$webclient.Credentials = $credentials; Get-ChildItem

# “For Each” loop will upload all of the files one by one onto the destination using the UploadFile method

Get-ChildItem $path | ForEach-Object { $webclient.UploadFile($destination + “/” + $_.Name, “PUT”, $_.FullName)};

Note: User need to have an access to the SharePoint list to upload the documents.

How to Insert a sequential unique integer ID value in a CSV file using PowerShell

#Import the CSV file data into Variable and add the blank new ID column

$CSV = import-csv “D:\Temp File\Temp.csv” | select Employee_ID, @{Name=”Id”;Expression={$_.””}}

# so we start from ID = 1 in the CSV file


# this will loop each row in CSV and insert the incremental unique ID value

FOREACH($ReadData in $CSV) {$ReadData.Id=$x;$x++}

#Export the data from the Variable to new file

$CSV| export-csv “D:\Temp File\Temp1.csv” -NoTypeInformation

How to Concatenate two column values in a CSV file Using PowerShell

#Import the CSV file in the Variable and Select the column names that you want to be displayed into #updated CSV file

$CSV = import-csv “D:\CSV File\Temp.csv” | select Surname,Given_Names,Email_Address,Employee_ID,Employee_Number,User_Name,Position_Title,

@{n=’ResourceName’;e={$_.Surname + ” ” + $_.Given_Names}}

# script @{n=’ResourceName’;e={$_.Surname + ” ” + $_.Given_Names}} will create the new #column Resource name and concatenate the Surname and Given_Names Column Value

# Export the data from the Variable $CSV to the new file

$CSV | export-CSV “D:\Temp File\Temp1.csv”

How to call the WCF Web Service in PowerShell?

# Create the WebSvcURL variable and pass the WSDL URL

$WebSvcURL= “http://snwebtt09/aurTEST/servlet/services/EV397_AURION_WS?wsdl

#Create the Web Service Proxy Object

$proxy = New-WebServiceProxy -Uri $WebSvcURL -Namespace ExportTool  -Class Program -UseDefaultCredential


Write-host -ForegroundColor DarkBlue ===successfullyconnected to the WCF Web Service $proxy

Note: Default User account need to have an access to invoke the WCF Web Service.