r/PowerShell • • Feb 22 '23

Question Hi all, I need help in combining 2 functions for my powershell profile. Please read below.

0 Upvotes

The first one is :

function prompt

{

  $loc = $executionContext.SessionState.Path.CurrentLocation;

  $out = "PS $loc$('>' * ($nestedPromptLevel + 1)) ";

  if ($loc.Provider.Name -eq "FileSystem") {

$out += "$([char]27)]9;9;`"$($loc.ProviderPath)`"$([char]27)\"

  }

  return $out

}

And the second one :

function Prompt

{

$promptString = "PS " + $(Get-Location) + ">"

Write-Host $promptString -NoNewline -ForegroundColor DarkGreen

return " "

}


r/PowerShell • • May 29 '17

PHP/HTML site "Web Portal ) run by IIS WebServer that allow to create AD users account with Powershell and PHP for RADIUS login and add group security policy to it.

Thumbnail
youtu.be
0 Upvotes

r/PowerShell • • Apr 30 '14

Information The FCC has offered an e-mail address for users to voice their thoughts on the agency's upcoming neutrality rules: [email protected]

Thumbnail
dslreports.com
0 Upvotes

r/PowerShell • • Jan 03 '19

Create a Portable Encrypted Password

0 Upvotes

By portable, we mean you can generate the encrypted password in PowerShell on one computer and use it on other computers with different user accounts, not just the computer it was created on.

Get The Code


r/PowerShell • • Jul 24 '23

Question Is there a way for me to close a powershell script after its finished?

0 Upvotes

I have this really simple script that installs a spotify extension and I want it to run on startup AND close after it's finished.

I managed to make it run on startup by making a shortcut and putting said shortcut in the startup folder, however I want it to close when finished, is there any way for me to do that? I have it run minimized so please don't recommend that and the script takes maybe 30sec-2min to run depending on internet im guessing.

This is the entire script.

iwr -useb https://raw.githubusercontent.com/spicetify/spicetify-cli/master/install.ps1 | iex

iwr -useb https://raw.githubusercontent.com/spicetify/spicetify-marketplace/main/resources/install.ps1 | iex

Edit: I was stupid and I didn’t see the -noexit in the code for the shortcut haha, thank you all for your help anyway!


r/PowerShell • • Jul 05 '21

Question Powershell bugged, cant batch rename files

0 Upvotes

Can anyone help please? I'm really frustrated.
I need to add certain prefix to name of every file in a directory.
I'm using this: dir | Rename-Item -NewName {"EN " + $_.Name}

This command worked perfectly for about 400 files so far, but today for whatever mysterious reason, the very same command (no typos, I pulled it out from history by pressing UP arrow) errors out saying I cant exceed 260char limit. It keeps naming the files in loop. So for example "video.mp4" is not renamed to "EN video.mp4" but "EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN EN video.mp4"

Any ideas how do I fix it please?


r/PowerShell • • Apr 12 '24

"Net use" vs. New-PSDrive

0 Upvotes

There really are some fundamental differences between "net use" and New-PSDrive and I think it's incorrect to assume that New-PSDrive is a drop-in replacement for "net use."

The use case that I found an issue with is this:

New-PSDrive -Name "X" -PSProvider "FileSystem" -Root \\someserver\someshare
$myDirectory = Get-ChildItem -Path X: -Include "targetdirectory" -Recurse -Force    

The problem arises when I then try to use the .Root or .FullName property of $myDirectory. They both provide the UNC path instead of
X:\somedirectory\somedirectory...

When mapping X: with "net use," .Root and .FullName return X:\somedirectory...


r/PowerShell • • Mar 06 '21

Script Sharing SSH to a Hyper-V guest without an IP address

0 Upvotes

Describing how you can ssh into a Hyper-V host without a IP address assigned and only the host name.

SSH to Hyper-V Virtual Machine using SSH.NET without IP Address


r/PowerShell • • Nov 10 '25

Is the below syntax outdated?

0 Upvotes

Greetings. Is the below code outdated? If it is not, what does “CN” and “DC” do? I’m trying to learn more about PS but the book I’m reading doesn’t explain what exactly those are and what it adds.

Set-ADUser -Identity “CN= Green Bill, CN= Users, DC= Manticore, DC= org” -OfficePhone “33333 55555”

I’m just trying to understand the purpose of CN and DC in the above code. Any help is appreciated.


r/PowerShell • • Mar 14 '25

Script Sharing Download Latest Firefox and Chrome automatically

0 Upvotes

I have developed a new PowerShell script that ensures the latest versions of Firefox and Chrome are consistently downloaded and installed. This script is designed to run as a scheduled task at regular intervals (e.g., daily) to keep your environment up to date and secure.

The next phase (script coming soon) will involve creating two packages via SCCM (for Chrome and Firefox) to ensure these applications are updated monthly across our servers. This is crucial, especially for enterprise environments with servers that do not have direct internet access.

The script will automatically update these packages, and SCCM collections will be triggered to initiate the update process. To ensure minimal disruption, you can set maintenance windows on the collections, allowing the installations to occur at specific times, ensuring that your systems are always secure and running the latest versions.

Check for yourself: https://github.com/ronaldnl76/powershell/tree/main/Download_Firefox_Chrome

Complex piece of code what getting the MSI File version

    function Get-MsiFileVersion {
    [OutputType([string])]
    param(
        [Parameter(
            Mandatory = $true,
            ValueFromPipeLine = $true,
            ValueFromPipelineByPropertyName = $true
        )]
        [ValidateNotNullOrEmpty()]
        [IO.FileInfo] $Path
    )

    Begin {
        $query = 'SELECT Property, Value FROM Property WHERE Property = ''ProductVersion'''
    }

    Process {
        if ($Path.Exists) {
            $windowsInstaller = New-Object -ComObject windowsInstaller.Installer
            try {
                $msiDatabase = $windowsInstaller.GetType().InvokeMember('OpenDatabase', 'InvokeMethod', $null, $windowsInstaller, @($Path.FullName, 0))
                $view = $msiDatabase.GetType().InvokeMember('OpenView', 'InvokeMethod', $null, $msiDatabase, ($query))
                [void] $view.GetType().InvokeMember('Execute', 'InvokeMethod', $null, $view, $null)
    
                do {
                    $record = $view.GetType().InvokeMember('Fetch', 'InvokeMethod', $null, $view, $null)
    
                    if (-not [string]::IsNullOrEmpty($record)) {
                        $name = $record.GetType().InvokeMember('StringData', 'GetProperty', $null, $record, 1)
                        $value = $record.GetType().InvokeMember('StringData', 'GetProperty', $null, $record, 2)
    
                        # Return the ProductVersion value
                        if ($name -eq 'ProductVersion') {
                            Write-Output $value
                        }
                    }
                } until ([string]::IsNullOrEmpty($record))

                # Commit database and close view
                [void] $msiDatabase.GetType().InvokeMember('Commit', 'InvokeMethod', $null, $msiDatabase, $null)
                [void] $view.GetType().InvokeMember('Close', 'InvokeMethod', $null, $view, $null)
            }
            catch {
                Write-Debug ('[Get-MsiFileInfo] Error Caught' -f $_.Exception.Message)
            }
            finally {
                $view = $null
                $msiDatabase = $null
                [void] [System.Runtime.Interopservices.Marshal]::ReleaseComObject($windowsInstaller)
                $windowsInstaller = $null
            }
        }
    }

    End {
        [void] [System.GC]::Collect()
    }
}

r/PowerShell • • Jan 05 '21

need contribution tool opensource to create a media drive boot universal

5 Upvotes

Hi everyone,

i'm finish i free tool, that permit to create a media boot drive to install Win10 universal, Support legacy and UEFI (with SecureBoot), you can also download any version of Win10 from official store

i'm also working to add iso generat by MDT and SCCM

thanks for your help

link is here : dakhama-mehdi/CMC-ISO: Tool to Create Media Windows 10 Boot (github.com)


r/PowerShell • • Jan 10 '26

[Open Source] PC Cleaner - A PowerShell-based Windows optimization toolkit with colorful UI (my first project!)

30 Upvotes

Hey everyone! Long-time lurker, first-time poster. I built a PowerShell tool for cleaning up Windows PCs and wanted to share it.

**What it does:**

- Quick Clean (temp files, browser caches, recycle bin)

- Startup Manager (disable bloat programs)

- Performance Mode (power plan, visual effects, Game Mode)

- Network Reset (DNS, Winsock, TCP/IP)

- Disk Analysis (visual breakdown of what's eating space)

- Backup/Restore (saves your settings before making changes)

**GitHub:** https://github.com/bradley1320/pc-cleanup

**The code is heavily commented in plain English** - I wanted anyone to be able to read it and understand exactly what every line does. If you're skeptical (you should be!), paste the whole script into ChatGPT/Claude/Grok or any other AI assistant and ask if it's safe.

Still learning, so feedback is welcome - even the harsh stuff! 🔥


r/PowerShell • • Aug 08 '26

Question Understand 10 year old powershell script using AI

0 Upvotes

What AI would you use to understand a decade old powershell script written by someone having 1000s of lines and plays a very crucial role for one of the function in an Org , between HR and AD. I would want the AI to explain me core functions , loop holes and maybe a visual representation of how the flow works with various conditions ( if, else and other exceptions ).


r/PowerShell • • Dec 04 '22

How do I delete the old windows folder?

2 Upvotes

square support bow knee combative noxious squealing close deliver resolute

This post was mass deleted and anonymized with Redact


r/PowerShell • • Sep 25 '22

Editing registry with powershell

2 Upvotes

Hi. I have a registry file I have created to change the default font of my windows 10.

I wonder if i can do this with powershell

this is my text I want in powershell.

even one line will be enough for me... I don't know how to write it.

thanx

Windows Registry Editor Version 5.00

[HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Fonts]

"Segoe UI (TrueType)"=""

"Segoe UI (TrueType)"=""

"Segoe UI Black (TrueType)"=""

"Segoe UI Black Italic (TrueType)"=""

"Segoe UI Bold (TrueType)"=""

"Segoe UI Bold Italic (TrueType)"=""

"Segoe UI Historic (TrueType)"=""

"Segoe UI Italic (TrueType)"=""

"Segoe UI Light (TrueType)"=""

"Segoe UI Light Italic (TrueType)"=""

"Segoe UI Semibold (TrueType)"=""

"Segoe UI Semibold Italic (TrueType)"=""

"Segoe UI Semilight (TrueType)"=""

"Segoe UI Semilight Italic (TrueType)"=""

[HKLM:\Software\Microsoft\Windows NT\CurrentVersion\FontSubstitutes]

"Segoe UI"="Tahoma"


r/PowerShell • • Oct 24 '20

Trying to find out router login credentials using PowerShell

2 Upvotes

I remember awhile back I forgot my routers login credentials and was able to recovery it without a factory reset. I though I ran PowerShell (maybe CMD) to find the information to login. the command used was

netsh wlan show profile "profile name" key=clear

this only shows me my wifi login. Am I missing a step after that command or am I using the wrong one?


r/PowerShell • • Mar 07 '18

(x-post from /widescreenwallpaper) I installed kubuntu as my operating system while fiddling with Ansible. Needed an ironic wallpaper

Post image
25 Upvotes

r/PowerShell • • Jun 09 '25

MIMIKATZ POWERSHELL !#SLF:HackTool:PowerShell/Mimikatz!trigger

0 Upvotes

I dont know what the hell this means, i just know the internet said it's meant to hack passwords. Defender cant remove, it gets blocked but reappears after 2 mins. Can I delete this in safe mode? Some people say powershell if critical and I'm afraid I'll get it wrong and corrupt my pc.

CmdLine: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noex -win 1 -enc aQBl


r/PowerShell • • Jul 27 '19

What if dangerous commands got stripey wasp-style syntax highlighting?

Post image
3 Upvotes

r/PowerShell • • Oct 21 '22

How can I get the same look and feel of Microsoft Stores's powershell screenshots?

3 Upvotes

I can't post images on this sub but if you open Microsoft Store you will see a fancy powershell look and fell. How can I turn it on on my pc?


r/PowerShell • • Feb 02 '23

My school has blocked command prompt, powershell etc bit i found a way to have unlimited powershell access. what should I do.

0 Upvotes

Using the python plugin named OS, I can open powershell and have unlimited access to every powershell command. I stumbled upon this after making a file that opens an image of shrek 500 times when opened. Then I thought I could do any command, however, I can't do any command and there are a few restrictions, such as an inability to do the ipconfig command. Then I opened powershell via the PowerShell command and could do IpConfig and every blocked command from the OS plugin.

btw im a bit of a noob with command prompt and powershell

Anyway, I want to do some stuff that wouldn't get me in too much trouble. What should I do?

update: im not gonna do anything


r/PowerShell • • Feb 18 '22

Question How do I remotely issue a command for executing the ".exe" file to all the windows domain computers at once?

6 Upvotes

I want all windows computers connected to the same Domain to want to get the ".exe" file and run it without physically visiting each machine. So I need a central way of distributing the .exe file and sending a command to run it.

How should i do this?


r/PowerShell • • Apr 16 '18

Powershell #Performance Tip

0 Upvotes

To make your #powershell go faster, you need to hashtag any slow line.

Put a '#' character at the start of any line that's too slow.... watch how fast it goes now!

~sorry


r/PowerShell • • Feb 27 '25

irm "https://christitus.com/win" | iex is it safe ?

6 Upvotes

irm "https://christitus.com/win" | iex

I want to run this command to optimise my PC, and I am confused about whether is it safe