Questions tagged [powershell-5.1]
280 questions
0
votes
2 answers
Fetching JSON with PowerShell - How do I fetch all keys under multiple arrays?
I'm trying to build a json file that'll be used in our diverse scripts to fetch our server details.
The same script will be used across all our environments that contains multiple products and components. Here's the kind of json file I'm working…

Seb Falardeau
- 37
- 3
0
votes
0 answers
How to find specific event ID in archivedlog
Hope you all are doing fine.
I have a question, i want to find a specific event id in a log that is archived but there are so many of them that i want go through each one of them
I have found a site on how you can do that…
0
votes
3 answers
I am unable to get splatting to work with New-ADUser using given and created attributes
I am processing an array of AD User data pulled from one domain to recreate in another. I have created a hash table linking the New-ADUser parameters with the user data imported from a CSV (populated from the domain I intend to recreate). When I…

GeoffS
- 3
- 3
0
votes
1 answer
Converting date string to DateTime (Aspose PDF Library)
I'm using the Aspose library within PowerShell and having some issues with the CreationDate values that Aspose is giving me back.
$pdf = New-Object Aspose.Pdf.Facades.PdfFileInfo($pdffile)
$pdf.CreationDate
This returns a string with the value…

Graham Reynolds
- 146
- 10
0
votes
1 answer
Powershell error running Get-dbaDatabase searching for missing backups
I am getting the following error when running this command:
Get-dbaDatabase -sqlinstance server01 -NoFullBackup
Error:
Compare-DbaCollationSensitiveObject : Cannot bind argument to parameter 'Value' because it is null.
At C:\Program…

packfan73
- 1
- 1
0
votes
2 answers
How to initialise a custom object list in Powershell 5.1?
What I want to achieve:
Create a list of files, show their name and version and sort alphabetically.
My attempt:
class File_Information
{
[ValidateNotNullOrEmpty()][string]$Name
[ValidateNotNullOrEmpty()][string]$FileVersion
}
$FileList =…

Dominique
- 16,450
- 15
- 56
- 112
0
votes
0 answers
Remove double quotation marks in the middle of the string field in a CSV file by using power shell
I am trying to remove the double quotation marks in the middle of the string field in a CSV file by using a power shell. Please find the attached sample data. Here is the code I am trying but it is not working. please suggest the best solution.…

DAR
- 47
- 6
0
votes
2 answers
Remove unnecessary commas in a column in csv file by using PowerShell
I am trying to Remove unnecessary commas in a column in the CSV file. For now, I know a few issues and hard-coded it, But I wanted the code to be dynamic. Any suggestions are greatly appreciated.
$FilePath = "C:\Test\"
Get-ChildItem $FilePath…

DAR
- 47
- 6
0
votes
1 answer
How to Redirect Input to SQL*Plus without Exiting using Windows PowerShell
Using Windows PowerShell, how do I redirect input into sqlplus (non-interactive stdin mode) such that once the redirected input is complete sqlplus is left open in interactive stdin mode without SQL*Plus exiting?
It appears as though the redirected…

Alex Bartsmon
- 471
- 4
- 9
0
votes
1 answer
How to skip a folder and its sub-folder and files from getting deleted using PowerShell?
I have a PS script which deletes the folders and files from a particular path older than 15 days.
I want to exclude "_tasks" folder and its contents from getting deleted but the scripts deletes the files and folders inside it even when I have…

SRP
- 999
- 4
- 21
- 39
0
votes
2 answers
Powershell Function with multiple parameters not accepting second pram
Trying to create a function that checks if you have a module installed along with that module being a minimum version. I have gotten it to work as a stand-alone check but when I try to make it function so that I don't have to have it repeated over…

Brian
- 23
- 4
0
votes
2 answers
Replace square bracket with new line in PowerShell
I have text per below (from an api response).
$a = '[
{
"Id": "65486432",
"RecordType": 20
},
{
"Id": "d1b2abe9",
"RecordType": 20,
"ModelsSnapshots": []
}
]
[
{
"Id": "65486432",
"RecordType": 20
},
{
…

woshishui
- 1,906
- 2
- 15
- 22
0
votes
1 answer
Cannot validate argument on parameter 'Container'. The argument is null or empty
I’m working on triggering an on-demand backup for my machines. But while running ps script it shows the below error.
"Cannot validate argument on parameter 'Container'. The argument is null or empty. Provide an argument that is not null or empty,…

Aditya c
- 3
- 1
- 4
0
votes
1 answer
Constructing a child class with instance of its parent class
I have a parent class with a lot of members. When constructing its child class, I'd like to avoid referencing the base constructor with a bunch of input arguments if possible.
Is it possible to construct a child class by inputting an object of its…

Blaisem
- 557
- 8
- 17
0
votes
2 answers
Why can't I execute remote scripts using powershell (5.1)
I have two computers on the same domain. winrm is running on both machines. Test-WSMan is running on the remote machine. I can execute invoke-command -scriptblock {dir c:\automatedtests} -computername RemoteComputername and it returns the expected…

Ben_G
- 770
- 2
- 8
- 30