Radu Grama http://OFFLINEZIP.wpsho On living with software, cloud, and other technologies. Thu, 15 May 2014 15:38:10 +0000 en-US hourly 1 https://wordpress.org/?v=5.2.2 "Sanitize" New-AzureStorageAccount's -StorageAccountName Parameter http://OFFLINEZIP.wpsho2014/05/15/sanitize-new-azurestorageaccounts-storageaccountname-parameter/ http://OFFLINEZIP.wpsho2014/05/15/sanitize-new-azurestorageaccounts-storageaccountname-parameter/#respond Thu, 15 May 2014 15:38:10 +0000 http://OFFLINEZIP.wpsho?p=531 If you automate New-AzureStorageAccount in a PowerShell script you ensure you only lowercase letters and digits for the value of the -StorageAccountName parameter. If you base that value on other parameters or variables (for example the name of one of your websites) and you have uppercase letters or dashes in those parameters or variables, you will see an error like this:
$storageAccountName = "Radu-Grama-Name"
New-AzureStorageAccount -StorageAccountName $storageAccountName -Location "East US"
VERBOSE: 10:29:20 AM - Begin Operation: New-AzureStorageAccount
New-AzureStorageAccount : Specified argument was out of the range of valid values.
Parameter name: parameters.Name
At line:1 char:1
+ New-AzureStorageAccount -StorageAccountName $storageAccountName -Location "East ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzureStorageAccount], ArgumentOutOfRangeEx
ception
+ FullyQualifiedErrorId : System.ArgumentOutOfRangeException,Microsoft.WindowsAzure.Command
s.ServiceManagement.StorageServices.NewAzureStorageAccountCommand

You need to “sanitize” the value of the -StorageAccountName parameter, and the easiest way to do it is to remove all non-lowercase letters and non-digits like this:
$storageAccountName = [Regex]::Replace($storageAccountName.ToLower(), '[^(a-z0-9)]', '')

Then you can run New-AzureStorageAccount as intended.

]]>
http://OFFLINEZIP.wpsho2014/05/15/sanitize-new-azurestorageaccounts-storageaccountname-parameter/feed/ 0
PowerShell one-liners to identify large Workflow History lists http://OFFLINEZIP.wpsho2012/01/23/powershell-one-liners-to-identify-large-workflow-history-lists/ http://OFFLINEZIP.wpsho2012/01/23/powershell-one-liners-to-identify-large-workflow-history-lists/#respond Mon, 23 Jan 2012 18:19:33 +0000 http://OFFLINEZIP.wpsho?p=34 One-liners

PowerShell script that will identify all Workflow History lists in the farm:

$farm = Get-SPFarm; $websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]}; foreach ($websvc in $websvcs) { foreach ($webapp in $websvc.WebApplications) { foreach ($site in $webapp.Sites) { foreach ($web in $site.AllWebs) { foreach ($list in $web.Lists) { if ($list.BaseTemplate -eq [Microsoft.SharePoint.SPListTemplateType]::WorkflowHistory) { [string]::Format("{0} ({1}) - {2}", $list.Title, $list.ItemCount, $list.ParentWeb.Url) } } } } } }

If you want to limit the lists identified to lists that have more than 1,000,000 rows:

$farm = Get-SPFarm; $websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]}; foreach ($websvc in $websvcs) { foreach ($webapp in $websvc.WebApplications) { foreach ($site in $webapp.Sites) { foreach ($web in $site.AllWebs) { foreach ($list in $web.Lists) { if ($list.BaseTemplate -eq [Microsoft.SharePoint.SPListTemplateType]::WorkflowHistory -and $list.ItemCount -ge 1000000) { [string]::Format("{0} ({1}) - {2}", $list.Title, $list.ItemCount, $list.ParentWeb.Url) } } } } } }

If you want to further limit to a certain web application:

$webapp = Get-SPWebApplication "http://sp"; foreach ($site in $webapp.Sites) { foreach ($web in $site.AllWebs) { foreach ($list in $web.Lists) { if ($list.BaseTemplate -eq [Microsoft.SharePoint.SPListTemplateType]::WorkflowHistory -and $list.ItemCount -ge 1000000) { [string]::Format("{0} ({1}) - {2}", $list.Title, $list.ItemCount, $list.ParentWeb.Url) } } } }

Feedback

Let me know if this helps!

]]>
http://OFFLINEZIP.wpsho2012/01/23/powershell-one-liners-to-identify-large-workflow-history-lists/feed/ 0
PowerShell one-liner to determine the incoming e-mail drop folder in SharePoint 2010 (incoming e-mail configured to automatic mode) http://OFFLINEZIP.wpsho2011/10/21/powershell-one-liner-to-determine-the-incoming-e-mail-drop-folder-in-sharepoint-2010-incoming-e-mail-configured-to-automatic-mode/ http://OFFLINEZIP.wpsho2011/10/21/powershell-one-liner-to-determine-the-incoming-e-mail-drop-folder-in-sharepoint-2010-incoming-e-mail-configured-to-automatic-mode/#respond Fri, 21 Oct 2011 14:23:17 +0000 http://OFFLINEZIP.wpsho?p=7 One-liner

Run this one-liner on each front-end Web server in the farm, as the settings on each of them may vary.

$s = [Microsoft.SharePoint.Administration.SPServer]::Local; $si = $s.ServiceInstances | where { $_.TypeName -eq "Microsoft SharePoint Foundation Incoming E-Mail" }; $si.ServerDropFolder

Feedback

Let me know if this helps!

]]>
http://OFFLINEZIP.wpsho2011/10/21/powershell-one-liner-to-determine-the-incoming-e-mail-drop-folder-in-sharepoint-2010-incoming-e-mail-configured-to-automatic-mode/feed/ 0
PowerShell one-liner to populate a SharePoint 2010 document library http://OFFLINEZIP.wpsho2011/09/02/powershell-one-liner-to-populate-a-sharepoint-2010-document-library/ http://OFFLINEZIP.wpsho2011/09/02/powershell-one-liner-to-populate-a-sharepoint-2010-document-library/#respond Fri, 02 Sep 2011 19:43:37 +0000 http://OFFLINEZIP.wpsho?p=9

One-liner

Just replace the values in $webName, $docLibName, $docFileName and $docCount with the website URL of your existing site, the existing document library you want to populate, the existing document you want to use for all items created, and the number of items you want to add to the document library.

$webName = ""; $docLibName = ""; $docFileName = ""; $docCount = 0; $web = Get-SPWeb -Identity $webName; $docLib = $web.Lists[$docLibName]; $folder = $docLib.RootFolder; $docFileInfo = Get-Item $docFileName; $fileStream = $docFileInfo.OpenRead(); $contents = new-object byte[] $fileStream.Length; $bytesRead = $fileStream.Read($contents, 0, [int]$fileStream.Length); $fileStream.Close(); for ($i = 0; $i -lt $docCount; $i++) { $spFile = $folder.Files.Add($folder.Url + "/" + $i + $docFileInfo.Extension, $contents, $true); $spItem = $spFile.Item; $spItem.Update(); }

Feedback

Let me know if this helps!

]]>
http://OFFLINEZIP.wpsho2011/09/02/powershell-one-liner-to-populate-a-sharepoint-2010-document-library/feed/ 0