528 questions
0
votes
0
answers
16
views
get-aduser seemingly returning more than one seperate array, that doesn't act like an array
I have the below code.
$AccountsMatching = (get-aduser -filter "name -like `"<User's name>*`"" -properties whencreated | select distinguishedname,whencreated,enabled)
...
0
votes
1
answer
84
views
Issue with converting string "0" to $false
I can't work this out. I am storing 0's and 1's in a CSV file, in the column named "Test". Using import-csv to read them back into Powershell, in an array, and in a for loop have used:
[...
0
votes
0
answers
35
views
How to programatically close a explorer.exe File Explorer window
Either I am using the wrong search term with Google, or unbelievably no-one has ever needed to close one of explorer.exe's File Explorer windows.
There is a program that my Powershell script launches ...
0
votes
1
answer
63
views
$String.split(",") not producing $null (or something useful to be used with a foreach loop), when no ,'s are present
Take for example:
$String = "this is a test"
$SeperatedStrings = $String.split(",")
foreach($String in $SeperatedStrings)
{
write-host "`"$String`""
}
**...
0
votes
0
answers
55
views
Can't get my Clear-Content script to work in Powershell
I have no prior experience with any scripting, so to me this script seems logical. I grabbed the lines off the internet and I feel like I'm missing alot. The script I'm trying to make is supposed to ...
0
votes
0
answers
84
views
Get All Documents Inventory in a Site using PowerShell-
For each site, we need to extract one entry per item in the document library, including the item’s name, location, and size.
I have tried below script
#Load SharePoint CSOM Assemblies
Add-Type -Path &...
-1
votes
3
answers
133
views
Powershell Write-Host Line Breaks In Different Scripts
I have 2 different scripts with line breaks. One of them won't make line breaks without "`n" at the end of each line. See this example with and without the "`n".
But other scripts ...
3
votes
2
answers
412
views
How to correct for PowerShell ISE string issue with external command on Windows 11
I have a PowerShell script (targeting 5.1) which when run using PowerShell ISE on Windows 10 works fine but in Windows 11 fails. The script pipes string literals to sqlite3.exe, for example
"....
0
votes
1
answer
70
views
Right click open new powershell file open in PSIDE
I'm still running windows 10 and I'm currently still running psh 5.1 due to company policy. I have local admin on my machine so I can write to the registry. I'm trying to figure out the quickest way ...
1
vote
2
answers
1k
views
How to enable IntelliSense Powershell Cmdlet/Parameter Suggestions DropDown Menu in VSCode Terminal like in ISE Terminal using CTRL+Space?
I am struggling to migrate working from Powershell ISE to VS Code for PowerShell programming.
The biggest issue so far is to get ISE-like experience. People writing on the internet about VS Code ...
0
votes
0
answers
45
views
Powershell grouping, sorting, retaining and moving files script balking at multiple directories? Folders? Volume of files?
I have a script (below) which works perfectly when run on one test directory on a network drive, but is not fully accurate when modified to be run on all the directories (27 in total) on the same ...
0
votes
0
answers
213
views
Auto-running Powershell script upon script tab opening (Powershell ISE)
I have a PS script that starts a batch file, which in turn calls a script which deletes and downloads files from SFTP.
Once all SFTP activities in the script are complete, the batch file then opens ...
1
vote
1
answer
97
views
Powershell ISE -MouseclickEvent
What are the steps in Powershell ISE to automate a click activity. I would appreciate the efforts to guide me from starting.
I tried using it sendkeys method and finding alternate to mouse click event ...
0
votes
2
answers
95
views
PowerShell ISE: Move duplicated files to another directory
I have to move older duplicated files into another directory while keeping the latest copy of each original filename. I need to keep them for a week in that location and then delete them. I have the ...
1
vote
1
answer
422
views
Issue with code in VS Code vs Powershell ISE
I have been trying to figure out why a script is working in Powershell ISE and not in VS Code. The script compares contents of the User folder and compares those folders with a partial name match to ...
0
votes
0
answers
504
views
PowerShell Exception calling "readkey"
Having issue with one arg in my minecraft server powershell script
line reads as follows
Exception calling "ReadKey" with "1" argument(s): "The method or operation is not ...
0
votes
1
answer
348
views
Deleting users in C drive and registry using PowerShell ISE
Code is not actually deleting users from the drive/reg
I did a little research and found some base code that I modified to apply to my situation at my job. Old users are a constant issue that I have ...
0
votes
1
answer
164
views
MacOS: Debug Powershell script admin privilege in VSCODE ISE
Using MacOS (M2 Chip):
I've Powershell script which I need to run as Administrator (sudo).
To debug the script I need to run the script in Debug mode from the pwsh prompt --but I don't know how can I ...
1
vote
1
answer
517
views
Trying to get a command to run in cli from a powershell script but it is picking up an "ambiguous" parameter
I am currently trying to get a command that I know works in CLI to run through a PowerShell Ise script but it will not allow me to run it as it is picking up a part of the command as a parameter.
I ...
1
vote
1
answer
596
views
Exception setting "TreatControlCAsInput": "The handle is invalid. in Windows PowerShell ISE
We have a PowerShell script that contains "[Console]::TreatControlCAsInput = $true". The script is executed in a Azure DevOps Pipeline and fails with
Exception setting "...
1
vote
0
answers
28
views
Powershell objects assigning values to object on the 'right side' of 'equal character' [duplicate]
I have a powershell script running steps such as
$stuffFromAPI = $resultsFromAPI.inputs.Stuff | ConvertFrom-Json
$objectFromAPIStuff = $stuffFromAPI.item[0] #ipAddress = 127.0.0.1
$newStuff = @()
$...
0
votes
0
answers
615
views
Find (Ctrl+F) dialog window in PowerShell ISE in Windows 11
In PowerShell ISE in Windows 11 (clean install), the Find dialog box no longer searches by pressing the Enter key. It appears the "Find Next" button is no longer set as the default button ...
0
votes
0
answers
358
views
PowerShell ISE Code to Visual Studio Code // Azure-AD Connection
I have the following Powershell-Script I wrote, which is working fine in Powershell ISE.
The problem is, I need it working in VS Code.
What is the script doing?
Well, it connects to an Azure Active ...
1
vote
1
answer
195
views
Remove leading timestamp (minutes) from PowerShell ISE
I am using PowerShell ISE and when I get an error, this weird timestamp is leading the error message and this is starting to get annoying.
Command:
PS C:\Users\serhat> terraform plan -var="...
0
votes
1
answer
2k
views
Checking active users in on-Prem AD via PowerShell - how can I do this via a CSV import?
I have a huge list of users that are present within an application, and I need to check whether all of them are present within on-Premises Active Directory. There's no way I'm going to be copying/...
0
votes
0
answers
110
views
How can I search for an PID for using an explicit handlename?
My goal is to search all Process from every user and search if someone is using an explicit dll that I already know at the start of my script. And when a User is running a Procces in which my ...
0
votes
1
answer
553
views
PowerShell - Populate my listbox with a selection made in drop down list
I am trying to make an Application Deployment tool on PowerShell ISE by pipelining the data through Active Directory for admins. Since Active Directory doesn't have a feature of fuzzy search, I ...
1
vote
0
answers
23
views
How to run a ps1 script from .net core web api [duplicate]
Here I've tried to create database out of the .bacpac with the help of .NET Core Web API using a PowerShell script. All I want to do is to pass dynamic parameters to the script from the API to create ...
0
votes
0
answers
529
views
DBATools and Overload SQLCommand and a clean ISE session
I have an older server with Powershell ISE, where I can't easily install vscode.
I am trying to run DBATools.io's invoke-dbaquery using the ISE, but I get 'cannot find an overload for "sqlcommand&...
1
vote
1
answer
2k
views
Writing a PowerShell script to copy directory and its contents to all users documents folder
First, this is my first REAL question on stack-overflow so here we go:
I am trying to use Get-ChildItem and Copy-Item to copy a directory and its contents to every user-profile that may be on a PC ...
0
votes
1
answer
46
views
Remove just the last "." in line
I don't now how to remove just the last "." in the end of line and don't impact the others "." in middle of line, this is an example :
"1","php.ect.D221211.T222012....
0
votes
0
answers
91
views
Where can I find more detailed help for ShowUI in Powershell?
I am unable to find clear information anywhere on how to use the ShowUI functions. I've created a function that searches for movie information in an effort to easily update my movie list. The ...
-1
votes
2
answers
439
views
Get all files named month by month
i have system of log that write logs each day with this format: "stat.dat_20220901_235900.txt","stat.dat_20220902_235900.txt",...
i need to get content of all files by month and ...
0
votes
0
answers
290
views
Map names for properties in Get-WinEvent
When I do this request
Get-WinEvent -FilterHashTable @{LogName='Microsoft-Windows-TerminalServices-Gateway/Operational'; Id=307,302,303; StartTime='01.11.2022 0:00:01'} | Select-Object TimeCreated, ID,...
0
votes
0
answers
49
views
Program completes even before completing all the Jobs and CPU memory continues to increase
I have created a PowerShell Program to execute multiple sql script files:
Below is my code in PS:
cls
$SQLSERVER = 'Servername'
$DATABASE = 'DB'
$USERNAME = 'Username'
$Password = 'Password'
$...
2
votes
2
answers
1k
views
Change the default "Edit" action for .ps1 from ISE to VS Code
Like the person in this question, it is frustrating that such obvious things have no clear answers (I've looked at 20 pages and found nothing yet).
The default right-click "Edit" action in ...
3
votes
2
answers
331
views
While working in Powershell, how do I pause between list items?
I have been working on this for a while and I cannot find this utilization anywhere. I am using a powershell array and the foreach statement:
@('program 1','program 2','program 3').foreach{winget ...
1
vote
0
answers
348
views
Does powershell have a "netonly" equivalent?
I want to open AD from a different domain. Earlier i used this to do so:
runas /netonly /user:xxxx\xxxx "mmc dsa.msc /domain=xxxx"
Which worked fine but i wanted to make it into a GUI to ...
0
votes
2
answers
1k
views
Try/Catch Script Failing to output $error to file
I am working on a script which will do the following:
Check if a service (in this case XboxGipSvc) is running
If service is running, do nothing
If service is not running, attempt to start service
If ...
0
votes
1
answer
682
views
AD Group Membership Export to separate columns
I'm looking to make a (hopefully) simple CSV or XLSX that I can use to compare two users' AD group memberships via PowerShell ISE. Currently, it's a bit extensive, though mostly this has been the &...
-2
votes
1
answer
566
views
move tab to another from several edge window at once with powershell
I have two windows Microsoft edge that have two tabs each. so I want to make PowerShell script when its run, the tab move to another tab in each edge.
0
votes
1
answer
166
views
How do I return the values of searched items in powershell instead of the object?
How do I fix this issue?
I am working on a code that will copy all of a single filetype (ie. txt, jpg, etc) to a single location so that I can suss out duplicates and manipulate them in one place. I ...
0
votes
0
answers
168
views
Powershell and VSCode Terminal issue
I'm having an issue regarding the Powershell extension in VSCode. I am getting a blank line, and a different command for the script being executed.
I get this on vscode:
PS>
PS>. "C:\...
2
votes
1
answer
837
views
Executable output works fine in PS console, but not in Powershell ISE?
I have an SAP program call sapgenpse.exe.
If i excute the below command from powershell command, the output is perfect.
But if i do the same operation in powershell ISE, the output breaks abruptly.
0
votes
3
answers
622
views
Move Files to a Backup Folder every first in the month and Zip the Files
I have never worked with powershell and I only need a program that is always run at the beginning of the month
What should the program do?
At the beginning of the month it should move all data except ...
0
votes
0
answers
138
views
Return Powershell ISE to the main window
I have written a script that starts by calling Firefox several times, then calls "a read-host". My problem is that I would like ISE or the console to come back in front of the other open ...
0
votes
1
answer
14k
views
What is the equivalent of $PSScriptRoot in Powershell ISE?
I am working on some scripts in Powershell ISE and I need PS script root to behave the same in Powershell and Powershell ISE. I made the following example to show the difference.
Caller.ps1
if ($psISE)...
1
vote
1
answer
2k
views
Script runs with ISE but not via PowerShell console
I have a script that runs smooth with ISE but stops when running via PowerShell console. Error raised:
You cannot call a method on a null-valued expression
So here is the code sample (can't show it ...
1
vote
1
answer
498
views
Do PowerShell ISE scripts produce system calls altering the entire OS down to the kernel?
I'm a complete rookie to programming. I will say so much off the bat: please go easy on me. I simply want to know what happens on a system-wide level when I run a script through the PowerShell ISE ...
0
votes
1
answer
1k
views
python not running in powershell ISE [duplicate]
when I type 'python' in either Windows powershell or the Command module (Windows 10), I get into the python environment. However, when I try the same in Windows Powershell ISE, I get an error message ...