Add Column to an existing CSV using powershell
Hi Everyone,
I am horribly stuck in building a logic of how can i add a column with certain details in an existing CSV using powershell. I tried many things one of the code is posted below.
The situation is , I have a Folder path ' D:\Exclusion\Final1' it contains a list of CSV's that looks like below:
preprocessed1.csv
CI,Environment
vm-Serv1,Test
preprocessed2.csv
CI,Environment
vm-bkp1,Prod
and so on with same structure..
Then I have another CSV that Contains certain list of Patches and Title
looks like:
Master_Exclusion.csv
Title, Patch
xyz, KB23109
abc, KB432344
yyy, KB321221
What I am Trying to do is to Copy the Column 'Patch' from here and copy them to all the CSVs present at ' D:\Exclusion\Final1'
and the output would look like :
preprocessed1.csv
CI ,Environment , Patch
vm-Serv1, Test ,KB23109
KB432344
KB321221
CI,Environment,Patch
vm-bkp1,Prod, ,KB23109
KB432344
KB321221
$filepathex=Get-ChildItem D:\Exclusion\Final1
foreach($fileex in $filepathex)
$exclusion=Import-Csv D:\Exclusion\Master_Exclusion.csv
$list=Import-Csv D:\Exclusion\Final1\$fileex
$list |
Select-Object *,@{Name='Patch';Expression={$exclusion.Patch}}} |
Export-Csv D:\Exclusion\Split2\$fileex -Append -NoTypeInformation
Thanks in Advance for any help or suggestions.
I am extremely sorry for the confusions , actually I am trying to just add a new column named "Patch" to a a list of existing CSV's . the patch column is present in another CSV i need to append it to the list of CSV's
Like
existing csv:
CI,Environment
vm-serv,Test
and another CSV is
Master_Exclusion.csv
Title,Patch
xyz,kb084932
yrx,KB893748
trw,kb949298
The output would be :
output.csv
CI,Environment ,Patch
vm-serv,Test,kb084932
KB893748
kb949298
Similar Messages
-
How does one add tables to an existing universe using COM designer SDK.
Morning All
How does one add tables to an existing universe using COM designer SDK. I have tried:
objUniverse.Tables.Add (strTable_Name)
but get "Cannot create Table" error.
Any ideas?
Thanks in advance.
AnitaHi Anita,
-Use the Add method to add classes and objects to an existing universe using a VB 6 application.
Adding a Class
Definition: Function Add(Name As String) As Class
Syntax: NameOfClassesVariable.Add
Adding an Object Instance
Definition: Function Add(Name As String, [ClassName As String]) As Object
Syntax: NameOfObjectsVariable.Add(name, [class])
- name is the name of the object.
- class is the name of the class containing the object. This parameter should be used in cases where more than one objects exist with the same name.
Sample Visual Basic 6 Code
Dim DesApp As Designer.Application
'MODIFY AND EXPORT CLASSES AND OBJECTS OF AN EXISTING UNIVERSE
Sub modify_and_export_universe()
Dim DesUnv As Designer.Universe
Dim DesCls As Designer.Class
Dim DesObj As Designer.Object
Dim DesDBCol As Designer.DBColumn
Dim DBColName As String
Set DesApp = New Designer.Application
'Login to designer
Call DesApp.LogonDialog
'Make sure to log on with your administrator profile
'e.g : "hostname","username", "password","Enterprise"
'Make Designer application visible
DesApp.Visible = True
'This line disable warning messages from Designer
DesApp.Interactive = False
'to Open locally the universe you want to modify
'Set DesUnv = DesApp.Universes.Open("club_uni")
'Use OpenFromEnterprise method (Universes Class) to import a universe from the repository and opens it
Set DesUnv = DesApp.Universes.OpenFromEnterprise("Universes", "club_uni", False)
'Add a valid connection which already exists
DesUnv.Connection = "club"
'open the universe
'Call DesApp.Universes.Open("club_universe")
'Add the table Account and refresh the view in the main window
Set DesTab = DesUnv.DBTables.Item("Customer").Insert
DesUnv.ArrangeTables
'Add a class
Set DesCls = DesUnv.Classes.Add("Class MyCustomer")
'Looping through all the fields of the DB Table Account
For Each DesDBCol In DesUnv.DBTables.Item("Customer").DBColumns
'Store name of the column
DBColName = DesDBCol.Name
'Add an object to the class
Set DesObj = DesCls.Objects.Add("Obj " & DBColName)
'Affect a field to the object
DesObj.Select = "Customer" & "." & DBColName
Next
'Save the existing universe with the same name club_uni or you can change
DesUnv.SaveAs "club_uni"
MsgBox "Universe created and saved Class MyCustomer has been added!!"
'Close the universe
UnvFullName = DesUnv.FullName
MsgBox "The UniverseFilePath is " & UnvFullName
'Close the universe
DesUnv.Close
'This line disable warning messages from Designer
DesApp.Interactive = False
'Export the universe to the CMS DB (to the last universe folder)
'Make sure you save the universe before exporting it
Call DesApp.Universes.Export("Universes", UnvFullName)
MsgBox "This document has been exported successfully !!"
'Close designer
DesApp.Quit
Set DesApp = Nothing
End Sub
Hope this helps.
Regards,
Deepti Bajpai -
Add columns in the existing Customer table in a Subject Area
Hi All,
Well I need to add two columns from Sales table(new table i created which has customer Id) and join it to the Customer Table which has the Customer Id and several columns. The Customer table was already in the RPD which has all the customer information. Now that i have this new requirement to add few columns from the Sales table to the Customer table in one Subject Area.
What i have done so far is that I imported the sales table into the rpd, made a join in PHYSICAL LAYER on the customer ID of the Sales table to the Customer id of the Customer table and simply dragged the sales table to the Customer LTS in the BMM layer(NO MORE JOINS IN BMM)and dragged and dropped the same into the Presentation layer. The customer table is linked to one fact table in that subject area. So i thought that dragging the sales table columns in the customer table LTS will work because customer is linked to one fact in that subject area.
Now, In the Answers when I dragged columns from customer & sales table I see only one record that is the first customer_id record from my Sales table but i know there are many common customer_ids between those two tables but its only picking the first customer id from the sales table.
Any help will be appreciated..
Normally if we need to add some columns to the existing tables in one subject area what is the best approach??Hi Balajee,
SAPMM06E 0111 CUSTSCR1 SAPLXM06 0111 Subscreen: PO item
for more information check with these links
ADDING NEW FIELDS IN me21n
ADDING NEW FIELDS IN me21n - (Screen exit / enhancment)
hope this will useful to you.
Regards! -
Add a list and column to about 200 sites using powershell in SharePoint online
I have a sitecollection with about 200 identical sites. However I need to add a new list to each site and a lookup column (referring to this list) to two other lists. I'm not a developer so I struggle a bit. I found this as a starting point:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") | Out-Null
$WebUrl = 'https://yourtenant.sharepoint.com/sites/somesite'
$EmailAddress = "[email protected]"
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($WebUrl)
$Credentials = Get-Credential -UserName $EmailAddress -Message "Please enter your Office 365 Password"
$Context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($EmailAddress,$Credentials.Password)
$List = $Context.Web.Lists.GetByTitle("YourList")
$FieldXml = "<Field Type='Text' DisplayName='New_Field_Display_Name' />"
$Option=[Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldToDefaultView
$List.Fields.AddFieldAsXml($fieldxml,$true,$option)
$Context.Load($list)
$Context.ExecuteQuery()
$Context.Dispose()
Can someone help me out or is there a better solution?
Thanks.
Hi,
According to your post, my understanding is that you wanted to add a list and a lookup column in about 200 identical sites.
Per my knowledge, there is no out of the box way to achieve it in SharePoint Server, however, I’m not sure whether it is in SharePoint online.
As this is the forum for SharePoint Server, you can post your question in the forum for SharePoint online.
http://community.office365.com/en-us/forums/154.aspx.
However, as you had known, we can achieve it programmatically.
Besides the PowerShell command, we can also use the Client Object Model to achieve your scenario.
If all the 200 sites in one site collection, we can first retrieve all the sites in the site collection, then add the list in every site.
To retrieve all the sites in a site collection, you can refer to the following code snippets.
static string mainpath = "SiteURL";
static void Main(string[] args)
getSubWebs(mainpath);
Console.Read();
public static void getSubWebs(string path)
try
ClientContext clientContext = new ClientContext( path );
Web oWebsite = clientContext.Web;
clientContext.Load(oWebsite, website => website.Webs, website => website.Title);
clientContext.ExecuteQuery();
foreach (Web orWebsite in oWebsite.Webs)
string newpath = mainpath + orWebsite.ServerRelativeUrl;
getSubWebs(newpath);
Console.WriteLine(newpath + "\n" + orWebsite.Title );
catch (Exception ex)
http://chennaisharepointtraining.blogspot.in/2011/11/get-all-subwebs-using-client-object.html
To create a list, you can have a look at the following article.
http://msdn.microsoft.com/en-us/library/office/fp179912(v=office.15).aspx
Thanks,
Jason
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected].
Jason Guo
TechNet Community Support -
How to update Column value in a list using powershell.
Hi All,
I am trying to copy value of One column to another column in same list. I am using SPSiteDataQuery for this. I am using following power shell script.
if ((Get-PSSnapin -Name Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue) -eq $null )
Add-PSSnapin Microsoft.SharePoint.Powershell
$CopyFromColumnName1 = "Section-1 Summary" #column copy source 1
$CopyToColumnName1 = "RichTextBoxControl" #destination column 1
$siteCollectionUrl = http://someURL
$site =new-object Microsoft.SharePoint.SPSite($siteCollectionUrl)
$query = new-object Microsoft.SharePoint.SPSiteDataQuery
$query.ViewFields = "<FieldRef Name='Title' /><FieldRef Name='PublishingPageLayout' /><FieldRef Name='FileLeafRef' /><FieldRef Name='RTC' /><FieldRef Name='SummaryOne' />";
$query.Webs = "<Webs Scope='SiteCollection'>"
$query.Lists = "<Lists ServerTemplate='850'/>"
$query.Query = "<Where>
<Contains>
<FieldRef Name='PublishingPageLayout' />
<Value Type='URL'>SomePageLayout</Value>
</Contains>
</Where>"
$spListItems = $site.rootweb.GetSiteData($query)
#Write-Host $spListItems
foreach($row in $spListItems.Rows)
$row.RTC = $row.SummaryOne
write-Host $row.RTC
$childWeb.Dispose()
$site.Dispose()
Here the column RTC is not updating on executing the script. I want to copy data from "SummaryOne" to "RTC" column.
Please assist me with this issue.
amolHi Bruno,
Thanks for reply I use following script and it is working for me.
if ((Get-PSSnapin
-Name Microsoft.SharePoint.Powershell
-ErrorAction SilentlyContinue)
-eq $null )
Add-PSSnapin
Microsoft.SharePoint.Powershell
#Use the Display Names
$webApplicationURL
= Read-Host
'Provide Site collection/Contnt HUB URL'
$webApp
= Get-SPWebApplication
$webApplicationURL
$CopyFromColumnName1
= "colName"
#column copy source 1
$CopyToColumnName1
= "coltoCopyVal"
#destination column 1
if($webApp
-ne $null)
foreach($siteCollectionUrl
in $webApp.Sites)
$site =new-object
Microsoft.SharePoint.SPSite($siteCollectionUrl.Url)
$query =
new-object Microsoft.SharePoint.SPSiteDataQuery
$query.ViewFields
= "<FieldRef Name='Title' /><FieldRef Name='PublishingPageLayout' /><FieldRef Name='FileLeafRef' /><FieldRef Name='RTC' /><FieldRef Name=’Name’ />";
$query.Webs
= "<Webs Scope='SiteCollection'>"
$query.Lists
= "<Lists ServerTemplate='850'/>"
$query.Query
= "<Where>
<Contains>
<FieldRef Name='PublishingPageLayout' />
<Value Type='URL'>PageLayout</Value>
</Contains>
</Where>"
$spListItems
= $site.rootweb.GetSiteData($query)
#Write-Host $spListItems
foreach($row
in $spListItems.Rows)
$listId
= $row["ListId"]
$webId =
$row["WebId"]
$childWeb
= $site.OpenWeb([GUID]($webId))
$pagesList
= $childWeb.Lists[[GUID]($listId)];
$itemUrl
= $childWeb.Url
+ "/"
+ $pagesList.RootFolder.Url
+ "/"
+ $row['FileLeafRef'].Split(';#')[2]
$listItme
= $pagesList.GetItemById($row.ID)
$listItme['RTC']
= $listItme[Name']
[Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges({
$listItme.SystemUpdate()
$childWeb.Dispose()
$site.Dispose()
else
Echo $webApplicationURL
"does not exist, check the WebApplication name"
Regards
Amol
amol -
How to add columns to an existing dimension on the fly?
Hey,
1) I already have a cube which is attached to three dimensions. Now if I wanted to add a few columns in the dimensions once they have been deployed, I find it difficult as the changes in the logical model and the physical table is not synchronized. Can some one please let me know, if adding columns to existing dimensions is possible?
2) I also had one more doubt. I have a fact table which has columns by the name parameter name and parameter value. Now once it is loaded I want to make certain calculations using a few parameters values and store them in the same fact table in the form of a new parameter name and the derived parameter value. How can I go about doing this part in OWB.
Thanks1. Yes you can add existing columns to a dimension, there are a couple of approaches; either add the columns to tje underlying table and then change the dimension to manual binding and add attributes to represent the columns. Or edit the dimension and regenerate the implementation table.
2. Could these not be just additional measures that you calculate in the cube load?
Cheers
David -
CEWB - add Columns to standard Table control using enhancement
hi,
there is a table control in CEWB where i want to add a field from table STPO. Is this possible to add fields to standard tble control. If yes, what is the method? Enhncement or i read somewhere GUIXT. Whats that?
Any help will be really appreciated.
I hv got some list of BADIs, but none of them re triggering in the "Component assignment" screen:
EWB_SELECTION
CEWB_TSK_MENU_INTERN
CEWB_TSK_MENU_EXTERN
CEWB_OPR_MENU_INTERN
CEWB_OPR_MENU_EXTERN
CEWB_COM_MENU_INTERN
CEWB_COM_MENU_EXTERN
CEWB_CHA_MENU_INTERN
CEWB_CHA_MENU_EXTERN
CEWB_MST_MENU_INTERN
CEWB_MST_MENU_EXTERN
CEWB_GEN_MENU_INTERN
CEWB_TSK_UPDATE
CEWB_TSK_SCREENS
ags.
Edited by: ags on Jan 20, 2012 7:11 PMhi,
I am able to do this using SAP GUIXT scripts. But since I am new to this Script would like to get some advice on it like is it best practice to use this technique in such situations? Also how do i make this change universl, like how should i deliver this develoipment to the customer nd other users? what kind of settings need to be done.
Any hint will be really helpul.
Thanks in advance.
Ags. -
Hi friends.
I want to build a script that obtains the collection of activities templates from a sr template (filtering the sr template by displayname) and export the list (template activities displaynames) to csv file.
Thanks for advance.
CheersImport-Module SMLets -Force
$templateName = "SS-Internas"
$template = Get-SCSMObjectTemplate -DisplayName $templateName
$templateAct = $template.ObjectCollection.PropertyCollection | Where { $_.Path -eq '$Context/Property[Type=''CustomSystem_WorkItem_Library!System.WorkItem'']/Title$'}
$report=@()
foreach($value in $templateAct.MixedValue){
$obj = New-Object PSObject -Property @{
"DisplayName" = $value
$report += $obj
$filePath = "E:\ACT_"+$templateName+".csv"
$report | export-csv $filePath -NoTypeInformation -Encoding UTF8
(Get-Content $filePath) | % {$_ -replace '"', ""} | out-file -FilePath $filePath -Force -Encoding UTF8 -
How to add columns for existing table dynamically?
Hi,
I created table structure only. I want to add columns for this existing table. Columns are not fixed, according to the user choice i need to write code.
Plz give me reply asap.
Thanks
ShirishaHi Shirisha,
I think the following code snippet will help you.
int l_no_cols = 0;
//Get the number of columns in this variable, something like the following
//l_no_cols = wdContext().currentContextElement().get<Context_attribute_name>;
IWDTable l_tab;
IWDTransparentContainer l_tbl_cont = (IWDTransparentContainer)view.getElement("TableDataCont");//ID of Container
l_tab = (IWDTable)view.getElement("TableData");//ID of Table
l_tab.setVisible(WDVisibility.VISIBLE);
l_tab.bindDataSource(wdContext.nodeTable_Data().getNodeInfo());
for(int a = 1; a <=l_no_cols; a++)
//Creating the column
IWDTableColumn l_tab_col = (IWDTableColumn)view.createElement(IWDTableColumn.class,"COL"+a);
//Creating Caption for Column Header
IWDCaption l_tab_cap = (IWDCaption)view.createElement(IWDCaption.class,"Caption"+a);
l_tab_cap.setText("Col"+i);
l_tab_col.setHeader(l_tab_cap);
//Creating Table Cell Editor for column
IWDInputField l_tab_cell = (IWDInputField)view.createElement(IWDInputField.class,"CellEditor"+a);
//creating context node attribute for the column dynamically
wdContext.nodeTable_Data().getNodeInfo().addAttribute("Col"+i,"com.sap.dictionary.String");
l_tab_cell.bindValue(wdContext.nodeTable_Data().getNodeInfo().getAttribute("Col"+i));
l_tab_col.setTableCellEditor(l_tab_cell);
l_tab.addColumn(l_tab_col);
l_tbl_cont.addChild(l_tab);
Regards,
Alka -
Get the pc name with domain name and add it to my properties file using commands
i want to get the pc name with domain name and add it to my properties file using powershell .
sidfunction Get-Environment{
[environment]|Get-Member -Static -MemberType Properties |
ForEach-Object{
if($_.Name -ne 'StackTrace'){
$v=[scriptblock]::Create("[environment]::$($_.Name)").Invoke()
New-Object PsCustomObject -Property ([ordered]@{Name=$_.Name;Value=$v[0]})
Get-Environment
Get-Environment | Out-String | Out-File environment.txt
¯\_(ツ)_/¯ -
How to export Listitems in sharepoint 2010 using powershell
I am able to export all items in sharepoint list by below command in powershell
Export-SPWeb -Identity
"http://myurl.com" - path
"C:\Export\Lists\Announcements.cmp" -ItemUrl
"/Lists/Announcements/AllItems.aspx" -Force
My list is having huge data in production I want to export only 10 items from the list using powershell. Is there any command to export only certain items.
I want to filter the Items and export only certain set of items using Export command.
RajendraHi all,
To export a list you can try:
Export data from SharePoint 2010 List using Management Shell: http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/MS-SharePoint/A_9182-Export-data-from-SharePoint-2010-List-using-Management-Shell.html
Export SharePoint 2010 List to Excel with PowerShell: http://iwillsharemypoint.blogspot.com.es/2011/02/export-sharepoint-2010-list-to-excel.html
Export SharePoint List Items to CSV using PowerShell: http://www.sharepointdiary.com/2013/04/export-sharepoint-list-items-to-csv-using-powershell.html
If a post answers your question, please click Mark As Answer on that post and
Vote as Helpful -
How to add calendar enries to all users in organization using powershell and EWS.
I am one of the exchange admins for our organization. Every year, we publish academic calendar data to all faculty and staff calendars. We recently updated and migrated from Exchange 2003 to Exchange 2010 which, of course, desupported MAPI and
ADO. The processes we previously used had to be re-written using Exchange Web Services API (EWS). Because I find that powershell is easy to work with, I wanted to integrate the calendar dispersal using powershell.
Having not found much help online using the EWS .NET library in powershell for this purpose, I decided to share my code:
# Bulk load calendar entries script
# Description:
# Script used to deploy Academic Calendar entries to all Exchange account calendars
# Prerequisites:
# Service account must have ApplicationImpersonation ManagementRoleAddisgnment
# New-ManagementRoleAssignment -Name:impersonationRole -Role:ApplicationImpersonation -User:<srv_account>
# Usage:
# .\academicCalendar.ps1 calEntries.csv
# Where calEntries.csv = list of calendar entries to add
Param ([string]$calInputFile = $(throw "Please provide calendar input file parameter..."))
$startTime = Get-Date
$strFileName = "<path to log file>"
if(Test-Path $strFileName)
$logOutFile = Get-Item -path $strFileName
else
$logOutFile = New-Item -type file $strFileName
# Load EWS Managed API library
Import-Module -Name "C:\Program Files\Microsoft\Exchange\Web Services\1.0\Microsoft.Exchange.WebServices.dll"
# Load all Mailboxes
$exchangeUsers = Get-Mailbox -ResultSize Unlimited | Select PrimarySmtpAddress
# Load all calendar Entries
# Input file is in the following format
# StartDate,EndDate,Subject
# 8/29/2011,8/30/2011,First Day of Fall Classes
$calEntries = Import-Csv $calInputFile
# Setup the service for connection
$service = new-object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010)
$service.Url = new-object System.Uri("https://<CAS_server_URL>/ews/exchange.asmx")
$service.Credentials = new-object Microsoft.Exchange.WebServices.Data.WebCredentials("<service_account>","<password>","<domain>")
$totalCount = $exchangeUsers.Count
$currentCount = 0
Write-Output "Exchange Version: $service.RequestedServerVersion"
Write-Output "Mailbox Count: $totalCount"
# Add message to log file
$timeStamp = Get-Date -Format "MM/dd/yyyy hh:mm:ss"
$message = "$timeStamp -- Begin Calendar Deployment `n"
$message += "Total Exchange Accounts: $totalCount"
Add-Content $logOutFile $message
# Perform for each Mailbox
$error.clear()
foreach($mailbox in $exchangeUsers)
$currentCount++
if($mailbox.PrimarySmtpAddress -ne "")
# Output update to screen
$percentComplete = $currentCount/$totalCount
Write-Output $mailbox.PrimarySmtpAddress
"{0:P0}" -f $percentComplete
# Setup mailbox parameters for impersonation
$MailboxName = $mailbox.PrimarySmtpAddress
$iUserID = new-object Microsoft.Exchange.WebServices.Data.ImpersonatedUserId([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SmtpAddress,$MailboxName)
$service.ImpersonatedUserId = $iUserID
# Indicate which folder to work with
$folderid = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Calendar)
$CalendarFolder = [Microsoft.Exchange.WebServices.Data.CalendarFolder]::Bind($service,$folderid)
# For each entry in the input file
$error.clear()
foreach($entry in $calEntries)
# First check to make sure the entry is not already in the calendar
# use a calendarview object to pull the entries for the given date and make sure an entry with the same subject line doesnt already exist
$cvCalendarview = new-object Microsoft.Exchange.WebServices.Data.CalendarView([System.DateTime]($entry.StartDate),[System.DateTime]($entry.EndDate))
$cvCalendarview.PropertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
$frCalendarResult = $CalendarFolder.FindAppointments($cvCalendarview)
$entryFound = $False
foreach ($appointment in $frCalendarResult.Items)
if($appointment.Subject -eq $entry.Subject)
$entryFound = $True
# If entry was found, then skip this entry
if($entryFound)
$entryFound = $False
else # Create the appointment object and save it to the users calendar
$appt = New-Object Microsoft.Exchange.WebServices.Data.Appointment($service)
$appt.Subject = $entry.Subject
$appt.Start = [System.DateTime]($entry.StartDate)
$appt.End = [System.DateTime]($entry.EndDate) #For AllDayEvent, end date must be after start date
$appt.IsAllDayEvent = $True #Set event as "All Day Event"
$appt.LegacyFreeBusyStatus = "Free" #Make sure free/busy info shows user as "free" rather than "busy"
$appt.IsReminderSet = $False #Make sure reminder is not set to remind the user of the event
$appt.Save([Microsoft.Exchange.WebServices.Data.SendInvitationsMode]::SendToNone)
if($error)
$timeStamp = Get-Date -Format "MM/dd/yyyy hh:mm:ss"
$message = $timeStamp + "...Exception Occurred while processing Save for: `n"
$message += " Account: " + $MailboxName + "`n"
$message += " Subject: " + $entry.Subject + "`n"
$message += " Exception: " + $error[0].Exception + "`n"
Add-Content $logOutFile $message
$error.clear()
if($error)
$error.clear()
else
$message = "" + $MailboxName + "`t Success! `n"
Add-Content $logOutFile $message
Write-Output $currentCount
$endTime = Get-Date
$duration = New-TimeSpan $startTime $endTime
$totalMin = $duration.TotalMinutes
# Build and send email notification upon completion
$body = "The Calendar deployment has completed. `n `n "
$body += "Start Timestamp: $startTime `n "
$body += "End Timestamp: $endTime `n "
$body += "Duration: $totalMin min `n "
$body += "Exchange accounts affected: $currentCount `n"
$smtpServer = "<mysmtpserver>"
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg = new-object Net.Mail.MailMessage
$msg.From = "<from_email_address>"
$msg.To.Add("<to_email_address>")
$msg.Subject = "Calendar Deployment"
$msg.Body = $body
$smtp.Send($msg)
# Add closing message to log file
$timeStamp = Get-Date -Format "MM/dd/yyyy hh:mm:ss"
$message = "Accounts affected: $currentCount"
Add-Content $logOutFile $message
$message = "$timeStamp -- Completed in $totalMin min."
Add-Content $logOutFile $message
Please let me know if you think I can make any performance modifications.
Daniel
--Edit-- I have updated the script for Exchange 2010 SP1, also added logging, error checking and email notifications. This new script also checks first to make sure the appointment doesn't already exist before adding it. (To prevent multiple
entries of the same event... Note: This check, although necessary in my opinion, is very time consuming.)Hi Daniel
I am trying to add addition propertires like TV, Copier etc. to Room Mailbox in Exchange 2010 using following commands:-
[PS] C:\Windows\system32>$ResourceConfiguration = Get-ResourceConfig
[PS] C:\Windows\system32>$ResourceConfiguration.ResourcePropertySchema+=("Room/Whiteboard")
Upper two commands run fine but following command gives error:-
[PS] C:\Windows\system32>Set-ResourceConfig -ResourcePropertySchema $ResourceConfiguration.ResourcePropertySchema
The term 'Set-ResourceConfig' is not recognized as the name of a cmdlet, function, script file, or operable program. Ch
eck the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:19
+ Set-ResourceConfig <<<< -ResourcePropertySchema $ResourceConfiguration.ResourcePropertySchema
+ CategoryInfo : ObjectNotFound: (Set-ResourceConfig:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I also tried with space after set but still getting error:
[PS] C:\Windows\system32>Set -ResourceConfig -ResourcePropertySchema $ResourceConfiguration.ResourcePropertySchema
Set-Variable : A parameter cannot be found that matches parameter name 'ResourceConfig'.
At line:1 char:20
+ Set -ResourceConfig <<<< -ResourcePropertySchema $ResourceConfiguration.ResourcePropertySchema
+ CategoryInfo : InvalidArgument: (:) [Set-Variable], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.SetVariableCommand
Pl advise the solution at [email protected] . I got this help from
http://zbutler.wordpress.com/2010/03/17/adding-additional-properties-to-resource-mailboxes-exchange-2010/ -
How to get DocSet property values in a SharePoint library into a CSV file using Powershell
Hi,
How to get DocSet property values in a SharePoint library into a CSV file using Powershell?
Any help would be greatly appreciated.
Thank you.
AA.Hi AOK,
Would you please post your current script and the issue for more effcient support.
In addition, to manage document set in sharepoint please refer to this script to start:
### Load SharePoint SnapIn
2.if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
3.{
4. Add-PSSnapin Microsoft.SharePoint.PowerShell
5.}
6.### Load SharePoint Object Model
7.[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)
8.
9.### Get web and list
10.$web = Get-SPWeb http://myweb
11.$list = $web.Lists["List with Document Sets"]
12.
13.### Get Document Set Content Type from list
14.$cType = $list.ContentTypes["Document Set Content Type Name"]
15.
16.### Create Document Set Properties Hashtable
17.[Hashtable]$docsetProperties = @{"DocumentSetDescription"="A Document Set"}
18.$docsetProperties = @{"CustomColumn1"="Value 1"}
19.$docsetProperties = @{"CustomColum2"="Value2"}
20. ### Add all your Columns for your Document Set
21.
22.### Create new Document Set
23.$newDocumentSet = [Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet]::Create($list.RootFolder,"Document Set Title",$cType.Id,$docsetProperties)
24.$web.Dispose()
http://www.letssharepoint.com/2011/06/document-sets-und-powershell.html
If there is anything else regarding this issue, please feel free to post back.
Best Regards,
Anna Wang
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected] -
How to update managed metadata column for all file in document library using powershell
Hi,
How to update managed metadata column for all file in document library using powershell?
Any help on it.
Thanks & REgards
Poomani SankaranHi TanPart,
I have changed the code which you have give in order to get the files from SharePoint 2010 Foundation Document Library.But i am getting below error in powershell.
Property 'ListItemCollectionPosition' cannot be found on this object; make sure it exists and is settable.
Could you tell me which is the issues in it?
See the code below.
$web = Get-SPWeb http://ntmoss2010:9090/Site
$list = $web.Lists["DocLib"]
$query = New-Object Microsoft.SharePoint.SPQuery
$query.ViewAttributes = "Scope='Recursive'";
$query.RowLimit = 2000
$caml = '<Where><Contains><FieldRef Name="Title" /><Value Type="Text">Process Documents/Delivery</Value></Contains></Where>' +
'<OrderBy Override="TRUE"><FieldRef Name="ID"/></OrderBy>'
$query.Query = $caml
do
$listItems = $list.GetItems($query)
$spQuery.ListItemCollectionPosition = $listItems.ListItemCollectionPosition
foreach($item in $listItems)
#Cast to SPListItem to avoid ambiguous overload error
$spItem = [Microsoft.SharePoint.SPListItem]$item;
Write-Host $spItem.Title
while ($spQuery.ListItemCollectionPosition -ne $null)
Thanks & Regards
Poomani Sankaran -
How to add hash table values to SQL Table using Powershell
Hi,
I have sharepoint list with four(column1, column2, column3,column4)columns.I am reading the list column values and adding to hashtable. Now I want to add values from hastable to SQL table with four(column1, column2, colum3,column4)columns using powershell.
I have written the following script for single column but I would like to know how to add values for multiple columns.
if(($key -eq "Column1") )
$SqlQuery = "INSERT INTO [TableName] ([Column1]) VALUES ('" + $HashTable.Item($key) +"')"
#Set new object to connect to sql database
$connection = new-object system.data.sqlclient.sqlconnection
$Connection.ConnectionString ="server=SQLServerName;database=SQLDBName;Integrated Security = True;"
$connection #List connection information
$connection.open() #Open Connection
$Cmd = New-Object System.Data.SqlClient.SqlCommand
$Cmd.CommandText = $SqlQuery
$Cmd.Connection = $connection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
$SqlAdapter.Fill($DataSet)
$DataSet.Tables[0]
$connection.Close()
Can anybody please help me out to accomplish the task? Any help would be greatly appreciated.
AA.Hi AOk2013,
Not knowledgable on PowercShell, based on my understanding on HashTable in Java, Some modification you can make in your code to achieve your requirement.
If the Keys in HashTable are "Column1","Column2","Column3","Column4", you can reference below.
if(($key -eq "Column1") ) #what is the purposed of this if ?
#$SqlQuery = "INSERT INTO [TableName] ([Term]) VALUES ('" + $HashTable.Item($key) +"')"
#specify the real column names in the table
$SqlQuery = "INSERT INTO [TableName] ([ColumnA],[ColumnB],[ColumnC],[ColumnD]) VALUES ('" + $HashTable.Item("Column1") +"','"+ $HashTable.Item("Column2") +"','"+$HashTable.Item("Column3") +"','"+$HashTable.Item("Column4") +"')"
#Set new object to connect to sql database
$connection = new-object system.data.sqlclient.sqlconnection
$Connection.ConnectionString ="server=SQLServerName;database=SQLDBName;Integrated Security = True;"
$connection #List connection information
$connection.open() #Open Connection
$Cmd = New-Object System.Data.SqlClient.SqlCommand
$Cmd.CommandText = $SqlQuery
$Cmd.Connection = $connection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
$SqlAdapter.Fill($DataSet)
$DataSet.Tables[0]
$connection.Close()
Since your question is regarding PowerShell, I would suggest you post it in a dedicated
PowerShell Forum. It is more appropriate and more experts will assist you.
If you have any feedback on our support, you can click
here.
Eric Zhang
TechNet Community Support
Maybe you are looking for
-
Re: purchasing info record.
Hi guru's, The specific vendor supplies different materils for diff., plants in a company code, Now the problem is how can I assign at a time a tax code, for diff., pur info record of material & vendor. waiting for replies tuljasingh.
-
I want to have one default ringtone for calls from people who are not in my address book. I would also have a distinct ( different) ringtone for those people IN my address book.
-
Where can i find some real-life flex applications?
Hi, i am trying to find some real-life flex applications. previously, there is a list of application in :http://flex.org/showcase/ but, now (after site reconstruction?), the list is gone. anyone have that list of applications? or could you
-
"Quicktime is not installed on this system"
It's a snow day, I'm supposed to be working from home and I just downloaded AE CC so I can do some work. Prior to this, I only had AE 5 on this iMac (running OS 10.9.5), but AE CC is refusing to open without trouble. I've tried these solutions: solut
-
Passing parameter fr doGet to doPost via getRequestURI() /form
doGet in my doGet i hav a <form action = req.getRequestURI() method post> ......do stuff... <input type=hidden name=accno value=rs.getObject(4)> <input type=submit > </form> my doPost String accno = req.getParameter("accno"); out.println (accno) ----