Quantcast
Channel: /r/powershell – How to Code .NET
Browsing all 8793 articles
Browse latest View live

Shortcut to powershell with specific profile

I want to create a shortcut to powershell where it loads another profile instead of loading the default profile. How would you go about that? I could do something like: powershell.exe -NoProfile...

View Article


How do I output only the matching text of select-string and store it as a...

Hi, $status = Select-String -path "X:Fileslog.txt" -Pattern "Running" -CaseSensitive write-output "$output" + " " + "Ain't life grand?" It doesn’t work. How do I output only the matching text and...

View Article


Rename file on remote PC to name of Remote PC from Local PC

I want to rename a file on the C:/ of a remote PC to the hostname of that PC from my local PC. Right now I have: cd c:usersadmindesktopPSTools psexec @laptoptest1.txt -u domainadmin cmd.exe /c ren...

View Article

Need a script that bulk creates Active Directory users from a CSV file

Just need something basic that’ll get the job done submitted by /u/PeterFountains [link] [comments] The post Need a script that bulk creates Active Directory users from a CSV file appeared first on...

View Article

Quick Tip: Use PowerShell To See How Many Files Are In A Directory

submitted by /u/tomatwork [link] [comments] The post Quick Tip: Use PowerShell To See How Many Files Are In A Directory appeared first on How to Code .NET.

View Article


[Request]Looking for script to update folder attributes wherever the folder...

I need to update every users appdata folder with attrib /S /D /L -H -S C:Users%USERNAME%*AllFileswithinAppData* The issue I am running into how do I get the script to go into each Users directory...

View Article

This is the shortest I’ve managed to produce FizzBuzz. Can anyone beat me?

function FizzBuzz($Arr){ $Arr| % { $Out = $null if ($_ % 3 -eq 0){$Out = ("{0}Fizz" -f $Out)} if ($_ % 5 -eq 0){$Out = ("{0}Buzz" -f $Out)} if ($Out -eq $null){ return $_ } else { return $Out } } }...

View Article

Setting variables based on read-host input and it’s not working.

So I am capturing an office name using read-host and storing it in the $office variable, then forcing it to uppercase. Then I am using that value to set the $OU variable. However, $office and $OU...

View Article


What are my options for remote reporting over the internet?

Hi, I would like to update information from a host, over the internet (securely) from a powershell script. Ideally a(n) (interactive) CSV or SQL Database – but right now a flat file creation would do...

View Article


Menu driven script to create active directory users

So I am fairly new to power shell but am well versed in bash scripting. A lot of our customers are moving to office 365. Each time we create a new user we have to go and make a couple changes in adsi....

View Article

What’s faster than Foreach and Where-Object

I do a lot of data comparison between CSVs which a lot of times ends up like this $CSV-A = Import-CSV filename-a.csv $CSV-B = Import-CSV filename-b.csv Foreach ($r in $CSV-A) { $Data = $CSV-B | Where...

View Article

Loop to create new arrays

Hello, I am trying to create a new array for each file in a directory. The file quantity will be changing, so I cannot set a static amount of arrays. Within a loop, “$variable + $i” errors and various...

View Article

What’s your secret to creating O365 accounts easily?

I have to create a few O365 accounts each week and it’s just becoming so mundane and tedious, clicking and clicking and clicking and clicking… How do you do it? Is there a faster way than using the...

View Article


Possible Nested Foreach loop?

Hey all! I’m trying to come up with the simplest way to copy user profiles to a shared drive for an upcoming project. I’m not sure if this is correct or not as I’ve never done something similar to...

View Article

Alternative to Invoke-Webrequest for hosts without IE?

As the title suggests, I was wondering if there was some native way to download and parse HTML when IE isn’t present. I found a workaround that involves modifying the registry, but that workaround...

View Article


shorthand if-else to out-file?

I’m still a PoSh noob and my google-fu is pretty weak yet for this language so I apologize in advance if there is plenty out there and I’m wasting your time. I’ve got a script that loops through a...

View Article

Free Powershell eBooks

submitted by /u/SQLoverride [link] [comments] The post Free Powershell eBooks appeared first on How to Code .NET.

View Article


Does POSHGUI work with Active Directory?

I know as of right now it is not portable to desktop, only website. For those who don’t know: https://poshgui.com submitted by /u/mask_off [link] [comments] The post Does POSHGUI work with Active...

View Article

I got bored and made a script to see if things are on.

So another post elsewhere asked about taking action through a Powershell script if a VM is offline, I was bored, came up with some solutions but decided I could make it better. So I created a function...

View Article

Problem with using AD Objects as keys in a hashtable….

Hey there guys! So I’m working on a script that is going to generate communication to some users managers. Rather than send a manager 3 emails if they have three users affected I want to send them one...

View Article
Browsing all 8793 articles
Browse latest View live