Reddit » PowerShell
1,691 FOLLOWERS
A subreddit for Powershell users. PowerShell is a cross-platform (Windows, Linux, and macOS) automation tool and configuration framework optimized for dealing with structured data (e.g. JSON, CSV, XML, etc.), REST APIs, and object models.
Reddit » PowerShell
11h ago
I'm trying to compare variables. One set of variables is pulled from a .json file while the other is based on a client. Both sets are matching on my test machine lets say $org = 1 and $ORG_ID = 1 . This should be correct but it's not, I've included the output at the bottom. What are some potential issues I should look for to get this fixed?
#Profile Correct?
$JsonPath = 'C:\ProgramData\Cisco\Cisco Secure Client\Umbrella\data\OrgInfo.json'
if (Test-Path $JsonPath) {
$Profile = 'True: Json Profile Available'
} else {
$Profile = 'False: Json Profile Missing'
}
Write-Host $Profile
#CheckVars ..read more
Reddit » PowerShell
11h ago
In a batch file it’s
@echo off :loop taskkill /F /IM [taskhere.]exe timeout /t 90 /nobreak >nul goto :loop
This would consistently kill a task for 90 seconds without stopping. Can this be done in power shell?
submitted by /u/MisterPuffyNipples
[visit reddit] [comments ..read more
Reddit » PowerShell
11h ago
I want to create a shortcut file to a PDF document with arguments, so that when I double click it on Explorer, it will open the pdf file in my default PDF viewer at the page specified.
I can create such a shortcut in Explorer, by right clicking the PDF file then:
Clicking on "Create Shortcut"
Opening the properties dialog for the file
Replacing the entire string present in the target field with PDFXEdit /a page=87 "C:\temp\sample.pdf"
I would like a PowerShell means of doing the above, I tried:
set-shorcut -Path 'c:\temp\sample.pdf' -Arguments 'PDFXEdit /a page=87' | get-shortcut WindowSty ..read more
Reddit » PowerShell
11h ago
Good day.
I would like to create a text search script for a variety of file types. I began with .pdf. Decided to use Word to read this type.
$Word = New-Object -ComObject Word.Application
$Word.Visible = $false
$Word.Documents.Open('D:\Download\CV.pdf', $null, $true) | Out-Null
But when i do that i hit a snag in shape of a word's Convert file confirmation dialog window. Is there a way to avoid it?
Regards. Kamil.
submitted by /u/Koan_om
[visit reddit] [comments ..read more
Reddit » PowerShell
11h ago
I am trying to use Graph API via Powershell to create a list of all devices in Entra.
Get-MgDevice -All -Property AccountEnabled, DeviceId, DeviceOwnership, DisplayName, EnrollmentType, IsCompliant, IsManaged, OperatingSystem, ProfileType | select AccountEnabled, DeviceId, DeviceOwnership, DisplayName, EnrollmentType, IsCompliant, IsManaged, OperatingSystem, ProfileType | Export-CSV c:\Reporting\EntraDevices.csv -NoTypeInformation
That works well and gives me a good list of devices.
How do I add the UPN or UserID for each device as well?
This CSV will be going into PowerBi to enable me to do ..read more
Reddit » PowerShell
11h ago
Hello I have this script to push data. It uses invoke-restmethod to push data on to a website in json. I am using convertto-securestring "pwd" - asplaintext - force. Next I use New-object management.automation.pscredential for username& password.
Is this a secure way ? I don't know powershell much. Thanks
Script:
$Uri = 'URL' $Body = @{
u_parameter1 = 'value1' u_parameter2 = 'value2' u_parameter2 = 'value3' } | ConvertTo-Json
$Headers= @{"Accept"="application/json" "Content-Type"="application/json" }
$svc_pwd=ConvertTo-SecureString "PASSWORD" -AsPlainText -Force $svc_cred = New-Object Man ..read more
Reddit » PowerShell
11h ago
Hi all,
I've been looking through MSGraph and PowerShell modules today to try and assist a user. They have many, many calendars in a shared mailbox (best guesstimate of 250+ calendars) that I need to export the events from, they only need the subject, start date and end date attributes. The best progress I've made is to get a list of all the calendars in the shared mailbox from MSGraph using this endpoint:
https://graph.microsoft.com/beta/users/sharedmailbox@domain.com/calendars
Then using another endpoint (https://graph.microsoft.com/v1.0/users/sharedmailbox@domain.com/calendars/Calendar/eve ..read more
Reddit » PowerShell
18h ago
Hello all,
I am getting a new laptop to replace my desktop and it's going to be Azure joined vs OnPrem Domain joined, I still want to use the ADUC/GPM tools without having to remote connect into a domain controller. I had a shortcut on my old desktop to just click and it would take me in after I enter my Domain Admin credentials while being logged into the computer as my standard user. So I need help with a script/command I can make into a shortcut to run ADUC connect to X domain as X user and if possible not save creds and ask for them every time. Any help would be appreciated. My old shor ..read more
Reddit » PowerShell
18h ago
The company i am currently at, has had an admin account for about 20+ years. It still has the same password, and is also used for services on multiple machines.
As time has gone on, i have gone through servers and created separate service accounts to get rid of it as much as possible
Other than disabling the account and waiting for the screams, which i am very reluctant to do, due to the way the staff are here. I need a script, if possible, that can go through a list of our desktops and servers, to see whether the account has been logged in, and even better, if its running as a service.
Basic ..read more
Reddit » PowerShell
18h ago
Hi!
I'm a bit confused as to why this is not working:
I created a couple of psm1 modules within AzureReport/Modules that are supposed to get loaded.
Within Report/ I but in a AzureReport.psm1 file that is supposed (as far as I understood) to load the modules.
function AzureReport {
$functions = Get-ChildItem -Recurse ".\Modules\" -Include "*.psm1" | ForEach-Object { $_.FullName }
}
I created a manifest by using New-ModuleManifest and it created a psd1 file with the same name as the AzureReport.psm1 file in Report/
I took everything out and put it in C:\Users\Username\Documents\PowerShell\Modu ..read more