Questions tagged [powershell-5.1]
280 questions
0
votes
1 answer
"The multi-part identifier could not be bound" When using PowerShell to run a working SSMS query
Below is a working SSMS query, meaning it will run and produce the requested results in SSMS with no problems. But, I am trying to get this query to run in PowerShell in order to create a daily automated script. PowerShell simply puts the output of…

Ransome
- 101
- 6
0
votes
1 answer
PowerShell Get-CimInstance creates popup to select files
When I execute the Get-CimInstance command in a Window 2016 Server, it is showing a popup to select "How do you want to open this file?". Screenshot attached. The same command works fine in other servers.
How to fix this issue? Is this PowerShell…

user17632237
- 1
- 1
0
votes
2 answers
running winrm set winrm/config/Service '@{AllowUnencrypted="true"}' give Error number: -2147024894 0x80070002
running the command: winrm set winrm/config/Service '@{AllowUnencrypted="true"}'
on Windows server 2019, give the fallowing error:
WSManFault
Message
ProviderFault
WSManFault
Message = The system cannot find the file…

yehuda mazal
- 39
- 3
0
votes
0 answers
Finding SQL Service account in active Directory with powershell
Using Powershell I need to find check if the "NT Service\MSSQL$nameofServer" has the propery trustfordelegatin set to true at the domain Controller.
If this was a user account I would just do this:
get-ADuser userdummy -Properties…

Leo Torres
- 673
- 1
- 6
- 18
0
votes
1 answer
RegEx is it possible to escape the ' character when wrapped in ' '?
I have a PS Profile that I'd like to share with some other users, and ideally it will send them to their home directories automatically on loading. However, I've noticed that users like to change the name of the home variable to suit their…

Blaisem
- 557
- 8
- 17
0
votes
0 answers
Is there an alternative to a finally block that always executes and doesn't require a try block?
I have some lengthy scripts which involve dynamic processes that I'd like to guarantee close, e.g.,
start-transcript --> stop-transcript
[io.StreamReader]$file --> $file.close(); $file.dispose()
setting an environment variable for the script…

Blaisem
- 557
- 8
- 17
0
votes
0 answers
Setting new CIM instance values
I am trying to lock the local admin account on a remote computer that i'm connected to using a CIM session:
$CIMSession = New-CimSession -ComputerName ComputerOne -ErrorAction Stop
$adminCheck = Get-CimInstance -Query "SELECT * FROM…

Abraham Zinala
- 4,267
- 3
- 9
- 24
0
votes
0 answers
"An error occurred while creating the pipeline" with latest powershell version
When I execute this command:
PS C:\> PowerShell -ExecutionPolicy Unrestricted -EncodedCommand…

Getodac
- 119
- 7
0
votes
1 answer
Can I add a static overload to a standard PowerShell type?
I'm trying to configure a runspace pool for my latest script. I would like to pass some functions to this runspace pool. I found a potential way to do this from this link:
#Sample function pass to runspace pool (copied from link)
Function…

Blaisem
- 557
- 8
- 17
0
votes
1 answer
Building expression from list of numbers
I have a variable list of number (switch ports) that I need to build into a string that indicates which ports should be "included" and which should be "excluded".
Here is an example of the required format:
(Port 1[!(0-2 | 4-9)] | Port 4[!(0-3 |…

StackExchangeGuy
- 741
- 16
- 36
0
votes
0 answers
Script only loads hashtable once
The below function is supposed to add the the passed parameters, and values, to a hashtable for later use when setting the actual properties but. . . for a reason I can't understand, the hashtable is only displayed once, with just one set of…

Abraham Zinala
- 4,267
- 3
- 9
- 24
0
votes
1 answer
Posh-SSH is giving an error when in WorkFlow
I wrote a script to export rows from a SQL DB, encrypt them using PGP, then transfer them using POSH-SSH v2.3.0. It all works fine, until I put it in a PowerShell WorkFlow to run multiple at a time.
This particular line is the issue:
Set-SFTPFile…

alexander7567
- 665
- 13
- 35
0
votes
0 answers
I am confused with the behavior of the conditional statements in my Powershell script
I was testing the control flow of my script to see what direction I was going with it, and got some strange results. At first it all seemed to be working correctly, but I decided to test the other if statement first, and after this run I ran the…
0
votes
2 answers
Powershell - Move folder filtered on subfolders
What I have so far:
Get-ChildItem -Path "\\Networkdrive\Folder1\PROD- TEST\Successful" -Recurse |
Where-Object name -match '\w{10}_\w{3}' |
Move-Item -destination "\\Networkdrive\Folder1\Archive- TEST\Archive_PROD_TEST\Successful" -Verbose
Inside…

TheRapture
- 5
- 3
0
votes
1 answer
Powershell searching many strings at once with a loop
The purpose of the script below is to search for a given string in a particular folder. The script does not error. But the results are not correct.
If the search is done individually search for one string it works. Once the script is run in a loop…

Leo Torres
- 673
- 1
- 6
- 18