powershell-3.0

Powershell ConvertTo-SecureString ObjectNotFound

岁酱吖の 提交于 2021-02-19 05:42:26
问题 After upgrading to powershell 3.0 existing scripts stopped working with an error ConvertTo-SecureString : The term 'ConvertTo-SecureString' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + ConvertTo-SecureString + ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (ConvertTo-SecureString:String) [], CommandNotFoundException +

Powershell: Get-ADComputer from another domain returns OperatingSystem information blank/missing

旧街凉风 提交于 2021-02-16 17:54:05
问题 Trying to list all computers with their OS information that belong to another trusted domain, but OperatingSystem and OperatingSystemVersion returns blank values: Get-ADComputer -Filter * -Properties Name, OperatingSystem, OperatingSystemVersion -SearchBase "" -Server OtherDomain.com.au:3268 | Format-Table Name, OperatingSystem, OperatingSystemVersion Only the Name property is populated. If I run this, it returns alot of info, but the OS info is all blank: Get-ADComputer -Filter * -Properties

Powershell Invoke-RestMethod using Self-Signed Certificates and Basic Authentication - Any Examples?

强颜欢笑 提交于 2021-02-16 04:43:08
问题 I'm playing with a RESTful API and using the Firefox RESTClient plugin all is well. I can easily query the API. However, when I try to plug the same API call into powershell it doesn't work! I've tried the following code from various other posts which should rule out certificate issues but I still can not get this to work: # This nugget should help me to get around any self-signed certificate issues I believe $netAssembly =[Reflection.Assembly]::GetAssembly([System.Net.Configuration

How to update a COM+ applications and create its msi file using PowerShell?

坚强是说给别人听的谎言 提交于 2021-02-10 17:55:43
问题 I have a COM+ application installed on my machine which has two components. This COM+ application was created using an SetupCom.exe file which was made using C# code some years bac. It used to install and create a COM+ msi file , but now I don't have access to that code, and I need to remove one component from this COM+ application - which is no longer in use. So, I searched using google and I found some PowerShell scripts that remove the components from the COM+ application, but they don't

How do I POST from Powershell using Invoke-RestMethod

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-10 16:56:13
问题 As per https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7#example-2--run-a-post-request I am trying to invoke a simple POST method but getting some errors. My instruction is: $uri = "https://localhost:44355/api/job/machine-status"; #$machineName = HOSTNAME.EXE; $machineName = "simPass2"; $body = @{ Name = $machineName Status = "Complete" } Invoke-RestMethod -Method 'Post' -Uri $uri -ContentType 'application/json' -Body $body;

Change date format from “yyyymmdd” to “mm/dd/yyyy”

放肆的年华 提交于 2021-02-08 15:01:28
问题 I've tried a lot of different ways and I can't seem to get it right. Here is the code of what I have tried so far... [String]$dateValue = '20161212' [String]$dateStamp = $dateValue -f (Get-Date) [String]$dateStamp2 = ([datetime]::parseexact($dateValue, "yyyyMMdd", [System.Globalization.CultureInfo]::InvariantCulture)).Date [String]$dateStamp3 = ([datetime]::FromFileTime($dateValue)).ToString('g') Write-Host '$dateStamp = ' $dateStamp Write-Host '$dateStamp2 = ' $dateStamp2 Write-Host '

PowerShell Add-WindowsFeature unrecognized

时光总嘲笑我的痴心妄想 提交于 2021-02-07 11:16:17
问题 Thanks first of all for reviewing this. I've basically got a third-party agent software which allows me to execute PowerShell as LocalSystem. This allows me to easily run remote PowerShell commands without WinRM etc. The problem that i'm running into is that on some servers i'm not able to perform get-WindowsFeature or Add-WindowsFeature. An example of how i'm trying to achieve this is here: Import-Module ServerManager; Get-WindowsFeature; The output is as such: The term 'Get-WindowsFeature'

PowerShell Add-WindowsFeature unrecognized

只谈情不闲聊 提交于 2021-02-07 11:14:43
问题 Thanks first of all for reviewing this. I've basically got a third-party agent software which allows me to execute PowerShell as LocalSystem. This allows me to easily run remote PowerShell commands without WinRM etc. The problem that i'm running into is that on some servers i'm not able to perform get-WindowsFeature or Add-WindowsFeature. An example of how i'm trying to achieve this is here: Import-Module ServerManager; Get-WindowsFeature; The output is as such: The term 'Get-WindowsFeature'

Powershell 3.0 : Alternative to “Get-Volume”

独自空忆成欢 提交于 2021-02-07 07:28:09
问题 I'm trying to get various properties for each hdd-volume on the computer. I was using the cmdlet get-volume and then walking through it via foreach , but that cmdlet does not exist in Windows Server 2008. :( Does anybody know an alternative? I just need the drive letter, objectId/guid, free space, total space, and the name of each volume. 回答1: The WMI class Win32_Volume has the information you are looking for Get-WMIObject -Class Win32_Volume | Select DriveLetter,FreeSpace,Capacity,DeviceID

Powershell 3.0 - Workflows - Limit number of parallel execution

末鹿安然 提交于 2021-02-07 05:41:51
问题 I am cloning VMs on ESX server from template. Simplified code looks like this: Workflow Create-VM { $List = 1..500 foreach -parallel ($Elem in $List) { # Create VM ... # Configure created VM .. } } Create-VM Parallel execution is really helpful. Unfortunately in this case doesn't work pretty well. Too many parallel request are generated. I need to limit number of parallel execution to smaller number (for example 4). I was trying to change local Session Configuration (SessionThrottleLimit,