powershell

Using powershell to merge two folders and rename files based on source folder

北城以北 提交于 2021-02-08 11:21:51
问题 I have a set of files like this: 2015_09_22 |____ foo |____ common.ext |____ common.1.ext |____ common.2.ext |____ common.3.ext |____ bar |____ common.ext |____ common.1.ext |____ common.2.ext I want to merge them into a structure like this, using the source folder name as a string to prepend to the filename: 2015_09_22 |____ foo_common.ext |____ foo_common.1.ext |____ foo_common.2.ext |____ foo_common.3.ext |____ bar_common.ext |____ bar_common.1.ext |____ bar_common.2.ext The format of

Installing AppFabric 1.1 with PowerShell DSC results in modal dialog error

烂漫一生 提交于 2021-02-08 11:12:50
问题 I'm trying to automate the installation of AppFabric 1.1 on a Windows 2012 R2 server using PowerShell DSC. This is actually part of me trying to automate the SharePoint Foundation install and configuration, but AppFabric 1.1 is a pre-requisite. Below is a snippit from my DSC config script: Script InstallSharePointPreRequisites { GetScript = { Return "InstallSharePointPreRequisites" } TestScript = {$false} SetScript = { Start-Process -FilePath 'c:\temp\SharePoint\pre

Installing AppFabric 1.1 with PowerShell DSC results in modal dialog error

[亡魂溺海] 提交于 2021-02-08 11:12:34
问题 I'm trying to automate the installation of AppFabric 1.1 on a Windows 2012 R2 server using PowerShell DSC. This is actually part of me trying to automate the SharePoint Foundation install and configuration, but AppFabric 1.1 is a pre-requisite. Below is a snippit from my DSC config script: Script InstallSharePointPreRequisites { GetScript = { Return "InstallSharePointPreRequisites" } TestScript = {$false} SetScript = { Start-Process -FilePath 'c:\temp\SharePoint\pre

Powershel create new [pscustomobject] from [pscustomobject] properties count

纵饮孤独 提交于 2021-02-08 10:59:26
问题 Now i need to create new [pscustomobject] with the data of another [pscustomobject]. To create one report. With this new [pscustomobject], i will export to an excel. My code: Function ConvertTo-MultiArray { param( [Parameter(Mandatory=$true, Position=1, ValueFromPipeline=$true)] [PSObject[]]$InputObject ) BEGIN { $objects = @() [ref]$array = [ref]$null } Process { $objects += $InputObject } END { $properties = $objects[0].psobject.properties |%{$_.name} $array.Value = New-Object 'object[,]' (

Powershel create new [pscustomobject] from [pscustomobject] properties count

微笑、不失礼 提交于 2021-02-08 10:55:59
问题 Now i need to create new [pscustomobject] with the data of another [pscustomobject]. To create one report. With this new [pscustomobject], i will export to an excel. My code: Function ConvertTo-MultiArray { param( [Parameter(Mandatory=$true, Position=1, ValueFromPipeline=$true)] [PSObject[]]$InputObject ) BEGIN { $objects = @() [ref]$array = [ref]$null } Process { $objects += $InputObject } END { $properties = $objects[0].psobject.properties |%{$_.name} $array.Value = New-Object 'object[,]' (

Powershel create new [pscustomobject] from [pscustomobject] properties count

别说谁变了你拦得住时间么 提交于 2021-02-08 10:54:35
问题 Now i need to create new [pscustomobject] with the data of another [pscustomobject]. To create one report. With this new [pscustomobject], i will export to an excel. My code: Function ConvertTo-MultiArray { param( [Parameter(Mandatory=$true, Position=1, ValueFromPipeline=$true)] [PSObject[]]$InputObject ) BEGIN { $objects = @() [ref]$array = [ref]$null } Process { $objects += $InputObject } END { $properties = $objects[0].psobject.properties |%{$_.name} $array.Value = New-Object 'object[,]' (

Powershel create new [pscustomobject] from [pscustomobject] properties count

时光怂恿深爱的人放手 提交于 2021-02-08 10:54:31
问题 Now i need to create new [pscustomobject] with the data of another [pscustomobject]. To create one report. With this new [pscustomobject], i will export to an excel. My code: Function ConvertTo-MultiArray { param( [Parameter(Mandatory=$true, Position=1, ValueFromPipeline=$true)] [PSObject[]]$InputObject ) BEGIN { $objects = @() [ref]$array = [ref]$null } Process { $objects += $InputObject } END { $properties = $objects[0].psobject.properties |%{$_.name} $array.Value = New-Object 'object[,]' (

Powershell trying and failing to cast a PSObject to Int32

好久不见. 提交于 2021-02-08 10:50:39
问题 $tabName = "EventsTable" #Create Table object $table = New-Object system.Data.DataTable "$tabName" #Define Columns $col1 = New-Object system.Data.DataColumn EventID,([Int32]) $col2 = New-Object system.Data.DataColumn EventDate,([datetime]) $col3 = New-Object system.Data.DataColumn Instances,([Int32]) #Add the columns $table.Columns.add($col1) $table.Columns.add($col2) $table.Columns.add($col3) #Enter data in the row $systemEvents = get-eventlog ` -newest 1000 ` -LogName System ` -EntryType

Powershell trying and failing to cast a PSObject to Int32

回眸只為那壹抹淺笑 提交于 2021-02-08 10:49:41
问题 $tabName = "EventsTable" #Create Table object $table = New-Object system.Data.DataTable "$tabName" #Define Columns $col1 = New-Object system.Data.DataColumn EventID,([Int32]) $col2 = New-Object system.Data.DataColumn EventDate,([datetime]) $col3 = New-Object system.Data.DataColumn Instances,([Int32]) #Add the columns $table.Columns.add($col1) $table.Columns.add($col2) $table.Columns.add($col3) #Enter data in the row $systemEvents = get-eventlog ` -newest 1000 ` -LogName System ` -EntryType

Unable to “Import Certificate” using API in PowerShell

邮差的信 提交于 2021-02-08 10:43:28
问题 I have a self signed certificate that I am trying to import to Azure Key Vault Certificate, and I am facing issues. I am not doing it using the Import-AzKeyVaultCertificate command, but using the API. I was successfully able to create a Key via the API route, but for the life of me, I am not able to Import a certificate. FYI, it also works when I do it over an Azure DevOps pipeline, so I know the Service Principle isn't the issue. Here's how I am creating the certificate (over PowerShell