119,263 questions
1
vote
1
answer
46
views
`Compress-Archive` with the `-Update` parameter erases the archive when given an empty list
I need to create a ZIP archive from a directory (data) with the following properties:
A specific file (.foo) needs to be the first item in the archive, uncompressed
The remaining files, if any, need ...
0
votes
0
answers
23
views
Local unit testing apache airflow
Cannot Run Apache Airflow Unit Tests: sqlalchemy.exc.OperationalError: unable to open database file
I am attempting to run a single unit test within the Apache Airflow repository (airflow-core/tests/...
1
vote
0
answers
36
views
Error "spawn code-tunnel.exe ENOENT" when forwarding ports on Windows 11
I am using the desktop version of Google's new IDE (Antigravity) on Windows 11. When I try to forward a port 5173 to preview my web application, I get the following notification error:
error
It seems ...
4
votes
2
answers
80
views
Trouble accessing a single element of an array in Powershell [duplicate]
I am attempting to use a single element of an array, when creating a string message, but it is using both elements, concatenated by a space, whether I use $myArray[0] or $myArray[1]...
# Multiple ...
2
votes
1
answer
99
views
How save specific strings and then put next to lines?
I'm parsing a file using powershell 5.1 and I almost get my goal but I need help in this part. The input file is like this:
CODE=MMH4
description=beg somedata - dduik
CODE=PPH2
description=beg Area1 -...
-1
votes
0
answers
35
views
How to replace string by new line in Powershell 5 [duplicate]
I have a file with some strings like below for which I want to replace the || with newline using powershell 5.1.
This is || some test || string
I've follow some advices in this thread and I'm trying ...
3
votes
2
answers
79
views
Verbose in class with "using module" directive
I faced a specific behavior while using verbose output in class.
This works like a charm:
# SomeModule.psm1
class SomeClass {
SomeClass() {
Write-Verbose "It works!"
}
}
...
-1
votes
0
answers
61
views
An ad_group_membership resource(hashicorp/ad) get error The command line is too long
I have a code which map users to group via a resource ad_group_membership from terraform provider hashicorp/ad
locals {
# --- Загружаем все YAML-файлы ---
yaml_be = yamldecode(file(var....
1
vote
1
answer
156
views
If statement with [string]::IsNullOrEmpty() always runs even if output is not null
$qusertest = quser | Out-String
if ([string]::IsNullOrEmpty($qusertest)){
Restart-Computer -Force
} else {
Write-Output $qusertest; exit 0
}
I am testing out code to automatically reboot ...
1
vote
1
answer
94
views
Powershell copy-item replaced a directory with a file
I'm using a command similar to the one below to copy a file to a directory:
copy-item 'C:\\some\\source\\directory\filename.txt' -Destination 'T:\some\destination\dir'
C:\ is a local disk. T:\ is a ...
2
votes
1
answer
114
views
How to delete Recycle Bin files older than 30 days for all users (running as SYSTEM from RMM)?
I'm building an script in PowerShell that runs via an RMM tool, so it executes in the SYSTEM context. The goal is to automatically delete files from the Recycle Bin that are older than 30 days, for ...
Advice
0
votes
5
replies
93
views
access module variables from outside of the module
I'm currently writing a helper module and despite my efforts, some private variable have to be accessed read/write from outside the module.
my first attempt was using Export-ModuleMember -Variable but ...
4
votes
2
answers
173
views
Illegal coercion operation producing inconsistent error/exception behavior depending on scope
Consider this example, a script named test.ps1
function MyTestFunction
{
[CmdletBinding()]
param ()
try
{
[bool]$functionBool= $null
}
catch {throw $_}
Get-...
0
votes
1
answer
526
views
Scripted installation of the PowerShell Active Directory (ActiveDirectory) module on Windows 11
In my PowerShell scripts I'm using the ActiveDirectory module, which contains the various *-AD* cmdlets such as Get-ADUser.
How can I automate (script) the installation of the PowerShell ...
0
votes
1
answer
58
views
Find and replace in Word doc with special characters
I'm trying to add commands to a powershell script that finds a username and password test and replaces them with the user's name and password. The issue that I'm running into is with special ...