tag:blogger.com,1999:blog-5150021777724050134.post3373763778658239807..comments2022-12-13T07:30:02.039-08:00Comments on Gazza's Corner: Sharepoint Part 6: Custom Project Systems on a ShoestringGary Nelsonhttp://www.blogger.com/profile/08730013754496401222noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-5150021777724050134.post-77800256996742142952013-01-28T01:13:08.981-08:002013-01-28T01:13:08.981-08:00Hi Sergio
Apologies for the very late reply. I ju...Hi Sergio<br /><br />Apologies for the very late reply. I just came across it.<br /><br />It looks like $var1 is not defined - and so $url may be concatenating with NULL (resulting in NULL).<br /><br />One of the things you need to be aware of in running PowerShell from within Sharepoint is that you only have a limited set of pre-declared variables, however you do have some very key ones available for the current Sharepoint context - particularly $item, among others.<br /><br />There may be some different base variables that are inherited in your PowerShell when running from Windows, compared to running within Sharepoint.<br /><br />One of the things that I did early on was to dump out the list of variables (standard output dumping to a file on the server) from PowerShell within Sharepoint - so I could see what I had to work with.<br /><br />I suspect you solved your problem but now - but I hope this bit helps as well.<br /><br />Gazza<br />Gary Nelsonhttps://www.blogger.com/profile/08730013754496401222noreply@blogger.comtag:blogger.com,1999:blog-5150021777724050134.post-39195944435203723972012-11-19T07:24:47.993-08:002012-11-19T07:24:47.993-08:00Hi Gazza, i have a problem and wonder if you can o...Hi Gazza, i have a problem and wonder if you can offer any advice. Im using the execute powershell workflow and it is failing even though i can run my script from a powershell window and it works fine however when i try and run it from within the workflow, i get "Error while executing PowerShell Script: You cannot call a method on a null-valued expression."<br /><br />Not sure what is wrong as all the variables are set and im not sure what is null. My workflow is running against a custom list and is creating a site collection with variables entered into the item when added to the list.<br /><br />so the user enters the name for their site collection, the description and the url and thats it, the script looks like this. $var1, 2 and 3 are set as workflow variables and are set to be the 3 pieces of info the user entered. ive also tried with no variables set like this and doing the change/lookup to the metadata direct into the script but same result.<br /><br />$url = "http://mydomain/sites/$var1"<br />$ContentDatabase = "contentDB"<br />$WebsiteName = "$var2"<br />$WebsiteDesc = "$var3"<br />$Template = "STS#0"<br />$PrimaryLogin = "admin account"<br />$PrimaryDisplay = "admins name"<br />$PrimaryEmail = "admins email"<br />$SecondaryLogin = "another admin account"<br />$SecondaryDisplay = "their name"<br />$SecondaryEmail = "their email"<br />$MembersGroup = "$WebsiteName Members"<br />$ViewersGroup = "$WebsiteName Viewers"<br /><br />Add-PSSnapin Microsoft.SharePoint.PowerShell –ErrorAction SilentlyContinue<br /><br />New-SPSite -Url $url –ContentDatabase $ContentDatabase -Name $WebsiteName –Description $WebsiteDesc -Template $Template -OwnerAlias $PrimaryLogin –OwnerEmail<br /> <br />$PrimaryEmail -SecondaryOwnerAlias $SecondaryLogin -SecondaryEmail $SecondaryEmail<br />$web = Get-SPWeb $url<br />$web.CreateDefaultAssociatedGroups($PrimaryLogin,$SecondaryLogin,"")<br />$PrimaryAdmin = Get-SPUser $PrimaryLogin -Web $url<br />$PrimaryAdmin.Name = $PrimaryDisplay<br />$PrimaryAdmin.Update()<br />$SecondaryAdmin = Get-SPUser $SecondaryLogin -Web $url<br />$SecondaryAdmin.Name = $SecondaryDisplay<br />$SecondaryAdmin.Update()<br />$web.Dispose()<br /><br />Any ideas?<br /><br />Regards<br /><br />Sergio Giusti<br />sergiogiusti@hotmail.comAnonymousnoreply@blogger.com