Questions tagged [powershell-5.0]

For issues relating to Windows PowerShell, version 5.0

Version 5.0 of Windows PowerShell, Microsoft's task automation and configuration management platform that functions as an interactive command shell and a scripting language. For general information about Windows PowerShell, see the tag wiki for the tag.

Windows PowerShell 5.0 is available as part of the Windows Management Framework (WMF) 5.0.

For the latest news and developments, check out the PowerShell blog.

909 questions
0
votes
2 answers

Can I stored class based DSC resource in separate file from PSM file?

Currently, for my modules, I store actual code in a separate file from PSM1 file, then dot source it and use Export-ModuleMember to export Functions, this way it allows me easily debug/test individual functions. I assume it's not possible since…
Gregory Suvalian
  • 3,566
  • 7
  • 37
  • 66
0
votes
1 answer

Powershell: looping through list of names from exchange query

My Goal is to apply a retention policy to newly created mailboxes. Details from previous article here. My Current Script code is located here for easy readability or below: # Get Start Time for script timer $startDTM = (Get-Date) #Authenticate…
0
votes
1 answer

Powershell return mailboxes created within 7 days and resides on specified server.

I need to automate applying exchange 2010 retention policy on mailboxes that have been created within 7 days. But i also need to exclude any non-US based servers as these are managed by IT overseas. This is the preface to my script that allows for…
0
votes
1 answer

PowerShell 5 remoting - JEA with RunAsCredential and Select-Object -Unique

I am trying to use PowerShell JEA (Just Enough Administration) on a Windows Server 2012 R2 server where I installed WMF 5. I need to make visible to a non-admin group of users 1 custom function only that relies on another locally installed module.…
0
votes
1 answer

Test ErrorRecord.CategoryInfo.Category in PowerShell

I'm attempting to handle an error based on its ErrorRecord.CategoryInfo.Category enumeration value. The code: try { # assembly not installed on workstation [Reflection.Assembly]::LoadWithPartialName('Oracle.DataAccess') # throws error…
craig
  • 25,664
  • 27
  • 119
  • 205
0
votes
0 answers

Not all data received from RedirectStandardOutput

I am working on a function that will invoke plink.exe to run commands on a remote non-Windows device. (In fact, this will be a more generalized function, but this is the use-case I am currently dealing with). In case the command does not work as…
Charlie Joynt
  • 4,411
  • 1
  • 24
  • 46
0
votes
2 answers

Generating MOFS for Partial Configurations using Configuration Names

I currently have nodes set up to pull their configurations from a http pull server (lab environment). The LCMs of these nodes are using configuration names to find their mofs. If I manually modify a mof to be the same name as the configuration name…
Phil J
  • 11
  • 3
0
votes
0 answers

DSC Unpredictable Imported Modules

There seems to be something buggy with DSC and PowerShell Modules. Resources that use the RemoteDesktop module randomly fail with the following error logged in DSC Operational event log If I run the same configuration ten times on ten different…
Jeff
  • 35,755
  • 15
  • 108
  • 220
0
votes
0 answers

Getting blanks while reading a CSV

I am trying to read a csv file and store in a hasmap. Below is the code I am using. $data | ForEach-Object { $ht = @{} $_.psobject.Properties | #Get only the grouped properties (that have a number at the end) Where-Object { $_.Name…
live2learn
  • 861
  • 2
  • 9
  • 16
0
votes
1 answer

Python to PowerShell, stem: Classes

What would be the posh equivalent for python's: class ControllerError(Exception): class OperationFailed(ControllerError): def __init__(self, code = None, message = None): super(ControllerError, self).__init__(message) self.code = code …
Jaqueline Vanek
  • 1,100
  • 10
  • 20
0
votes
1 answer

sqlcmd -v parameter ignored in PowerShell

I've read the documentation (sqlcmd Utility), but I can't get sqlcmd's -v parameter to work as expected. Assuming this SQL script (echo.sql): :setvar THE_PATH C:\Users\Craig\Desktop PRINT 'THE_PATH: $(THE_PATH)' :setvar THE_TOP 10 PRINT 'THE_TOP:…
craig
  • 25,664
  • 27
  • 119
  • 205
0
votes
1 answer

Powershell5 IndexOf behaviour changed - suggestions?

Having recently upgraded my workstation to Windows10 I've been checking all my old scripts and it seems that IndexOf is behaving differently. In PS4 this worked fine: $fullarray = $permissions | %{ $obj = new-object psobject $obj |…
Scepticalist
  • 3,737
  • 1
  • 13
  • 30
0
votes
2 answers

Can't change DSC LCM credential

When attempting to access a network shared folder, DSC returns an "Access is denied" error, despite that I have provided a valid credential to it. I'm using a DSC configuration, where a DSC "Script" resource is as follows: Script myScriptResource { …
Samer
  • 3,848
  • 4
  • 25
  • 24
0
votes
1 answer

Create a dynamic ReST request body in PowerShell

I am currently working on a use case for invoking ReST request in PowerShell. The body of POST request is created dynamically, reading data from a CSV file. Here is how my final request body should be { "@type": "mtTaskParameter", …
live2learn
  • 861
  • 2
  • 9
  • 16
0
votes
1 answer

DHCP PowerShell cmdlets from PC

Can I use DHCP PowerShell cmdlets from a Windows 10 desktop? I have searched online a lot but only come up with results about using the cmdlets from the server. If my PC is on the DHCP server I would think there is a way to use the cmdlets from my…
gannolloy
  • 163
  • 1
  • 1
  • 5