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

Export Exchange 2016, 2013, & 2010 Mailboxes Backup to PST using PowerShell Commands.


Allow non admin (and another for admin) users to remotely see who is logged on to a remote PC?

$
0
0

I need to allow non admin users to run a script and see who remotely is logged on to a remote workstation.

They would just type the name of the workstation and it would say

“The user $domainuser is logged on”

or it would say

“Noone is currently logged on”

Another script would do the same thing PLUS kick said user (or users) off

I dont want to (and can’t) play with adding AD attributes or anything of that sort

Thanks

submitted by /u/riahc4
[link] [comments]

The post Allow non admin (and another for admin) users to remotely see who is logged on to a remote PC? appeared first on How to Code .NET.

OutTabulatorView

$
0
0

I saw /u/jsnover retweet this module of Doug Finke (same person who created the awesome ImportExcel module). I thought this would have already been shared here but it looks not.

Seem’s a pretty powerful module for creating dynamic tables that run in a browser (not IE mind…).

https://github.com/dfinke/OutTabulatorView

It’s on the PowerShell Gallery.

Install-Module -Name OutTabulatorView 

submitted by /u/Swarfega
[link] [comments]

The post OutTabulatorView appeared first on How to Code .NET.

Updating AD Job Title using CSV

$
0
0

I hope that someone will be able to help me out with this!

I’m trying to update several hundred job titles using a CSV file that’s populated with email addresses and the new job titles.

This is what I’ve written in PowerShell so far but haven’t been able to make it work yet…

Import-Module ActiveDirectory $data = import-csv -path C:TempBook2.csv foreach ($user in $data){ Get-ADUser -Filter “Name -eq ‘$($user.mail)'” | Set-ADUser -Replace @{title = “$($user.role)”}} 

Feel as though I’m nearly there so any help or assistance would be greatly appreciated!

submitted by /u/CuttsAndBruises
[link] [comments]

The post Updating AD Job Title using CSV appeared first on How to Code .NET.

Display list of installed software including product keys

$
0
0

Hey, complete newbie to PS here so very sorry if my explanation is poor.

I came across the following command –

Get-ItemProperty HKLM:SoftwareWow6432NodeMicrosoftWindowsCurrentVersionUninstall* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize > 

Stolen from here.

I was wondering if it was possible to also include any applicable product keys, I’m particularly interested in getting the key for any office products installed on the machines in question.

I am currently using a bit of freeware from MSI Solutions that outputs this for me already, however I was hoping this could be completed through the use of a PS command without the need for relying on 3rd party software.

I’ve stumbled upon a number of links for functions that I have no idea how to integrate into what I already have. Could anyone give me a little nudge in the right direction / let me know if I’m going about it incorrectly?

submitted by /u/Bobby_FuckingB
[link] [comments]

The post Display list of installed software including product keys appeared first on How to Code .NET.

Finished New Starter

Trying to create a PowerShell scheduled checklist.. checker

$
0
0

Hi there.

I’m trying to keep all of our user info synchronized between our different directories (AD, G suite, Office365, CW).

What I wanted to start off with was checking the AD to verify the user’s mail priority is set and that the mail is the correct format.

I made a workflow to work out of which looks like this

https://i.imgur.com/qp5jO8s.png

I’ve started off with this when I realized, I don’t know how to go to the next check.

Next person is Continue anywhere in the loop but I’m not sure how to go about going to the next check.

The next check would be checking the phonenumber and then grabbing that from Google if it is not listed, then checking if they are created in office 365 and to see if they are created with the correct email format.

#Complete check #region - Check AD $OUs = "Ou1"#,"Ou2"#,"Ou3","Ou4","Ou5" #Add or remove OUs to check each user in. foreach ($OU in $OUs){ $adusers = get-aduser -filter * -SearchBase "OU=$ou,OU=Users,DC=domain,DC=tld" -Properties * | where-object Enabled foreach ($aduser in $adusers){ #endregion #Check email write-host -ForegroundColor magenta "-------------" write-host -ForegroundColor magenta "-- AD INFO --" write-host -ForegroundColor magenta "First name:" $aduser.givenname write-host -ForegroundColor magenta "Last name:" $aduser.Surname write-host -ForegroundColor magenta "Email:" $aduser.mail write-host -ForegroundColor magenta "-------------" #build alias $alias = "" $alias = $aduser.GivenName + "." + $aduser.surname + "@domain.tld" $alias = $alias.Replace(" ","") if($aduser.mail -eq ""){#IsADemailEntered? #if no write-host -ForegroundColor Red $aduser.GivenName $aduser.Surname" email in AD is empty?!" if (gam info user $alias){#DoesAliasExists? #DoesAliasExists-YES write-host -ForegroundColor cyan "$alias does exist" # #set-aduser with that mail # }else { #DoesAliasExists-NO write-host -ForegroundColor Yellow "$alias does not exist and can be used for a new google account for" $aduser.givenname $aduser.Surname }#end if no #DoesAliasExist }#finish if yes for }#finish #IsADemailEntered? }#finish AD user loop }#finish OU loop 

submitted by /u/sysadminworkaccount
[link] [comments]

The post Trying to create a PowerShell scheduled checklist.. checker appeared first on How to Code .NET.

got over a hurdle and onto the next, I have a API that I got the information I need but need formatted back

$
0
0

I am working with an API powershell call, I get my query results back fine; however, when exporting it seems it takes the object name instead of the results. if I do a | export-csv it messes up but if I go to | format-list it works. Is it possible to take a list format that I have in $results back to table format? for being exported to a csv?

submitted by /u/jdb5345
[link] [comments]

The post got over a hurdle and onto the next, I have a API that I got the information I need but need formatted back appeared first on How to Code .NET.


PS to sort files based on keywords in the filename.

$
0
0

I’m looking for a PS to look at the hundreds of files within as specific folder, then move files to other directories based on the name of the file.

ex. move all files containing “ocr” in the file name, into a folder called OCR. Move all files containing the word “logo” into a folder called logo. Then within each of those two folders, look for a list (about 130 names) and move the ones without those names into an “undetermined” folder.

I’m a complete novice with PS but I’m capable of reverse engineering others work to figure out how to make work for me. Honestly unsure where to start with this. Maybe PS isn’t the best option?

submitted by /u/NumerousImportance
[link] [comments]

The post PS to sort files based on keywords in the filename. appeared first on How to Code .NET.

different results running a script from a batch file

$
0
0

I wrote a script that parses folders for xml files and images. The script renames the images bases on info pulled from the xml. Everything works fine when I run the script from the ISE but when I execute it from a batch file, the first pass the ForEach doesn’t pull the information from the xml file. I saw something similar to this earlier, but I removed the variables from the end of each segment of the script and it fixed the issue. What am I doing wrong?

submitted by /u/edorbuddy
[link] [comments]

The post different results running a script from a batch file appeared first on How to Code .NET.

Edit SharePoint Edu Group site permissions

Anyone know of a script or query to detect if a smart card is in the card reader of a remote PC?

Powershell support for hosted 365 email

Extracting HTML tables into PSobjects?

$
0
0

I’m using Invoke-WebRequest to get some data from a website, some of the data that i want it in a table, but they didn’t use the standard table header tags so getting the information (in a format i want) it proving to be a pain in the A$$.

The HTML looks like this.

https://pastebin.com/aZTy9B4D

I’ve come across this http://www.leeholmes.com/blog/2015/01/05/extracting-tables-from-powershells-invoke-webrequest/ and it works wonders when the tables have correct table header tags. Without it, it adds “p1” “p2” so on for the table headers which is good and i can format it as a table and hide table headers but i can’t then manipulate the data like that i want..

How i am trying to get the output is like so.

Serial : 111111111 FW Ver : G92.T FW Ver : 9999 LastResync: 2018-05-31 20:32:16 Primary : ConfigName1.cfg secondary config: ConfigName2.cfg Third config: ConfigName3.cfg Serial : 222222222 FW Ver : G92.T FW Ver : 4vg554 LastResync: 2018-05-31 20:32:16 Primary : ConfigName1.cfg secondary config: ConfigName2.cfg Third config: ConfigName3.cfg 

I either need help on ways to extract the table table

OR using the script above, how to get the table data into a PsObject properly..

Any Ideas?

Thanks in Advance

submitted by /u/tadcrazio
[link] [comments]

The post Extracting HTML tables into PSobjects? appeared first on How to Code .NET.

Move all files with same extension from subfolders to current folder


Update AD LastLogonTimeStamp via PowerShell?

Infrastructure Testing with Pester and the Operation Validation Framework

trying to create a registry entry and getting error

$
0
0

I am very new to powershell for forgive me for the noob question. I did google this and could not get a clear answer on what Im doing wrong so I was hoping reddit could help.

I am trying to add a registry key and then at an item property.

When I run the portion that creates the key it says it succeeds but I haven’t seen the registry update with the key

When I try to add the item property I get an error and I don’t know what the error means.

here is the code

$registryPath = "HKEY_LOCAL_MACHINE/SOFTWARE/Policies/Google/Chrome" $Name = "IncognitoModeAvailability" $value = "1" IF(!(Test-Path $registryPath)) { New-Item -Path $registryPath -Confirm -Force New-ItemProperty -Name IncognitoModeAvailability -Path $registryPath -Confirm -Force -Value 1 } ELSE { New-ItemProperty -Name IncognitoModeAvailability -Path HKLM:SoftwarePoliciesGoogleChrome -Confirm -Force -Value 1} 

and here is the error im getting

PS C:WINDOWSsystem32> New-Item -Path $registryPath -Confirm -Force New-ItemProperty -Name IncognitoModeAvailability -Path HKEY_LOCAL_MACHINE/SOFTWARE/Policies/Google/Chrome -Confirm -Force -Value 1 Directory: C:WINDOWSsystem32HKEY_LOCAL_MACHINESOFTWAREPoliciesGoogle Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 6/1/2018 11:12 AM 0 Chrome New-ItemProperty : Cannot use interface. The IDynamicPropertyCmdletProvider interface is not implemented by this provider. At line:3 char:5 + New-ItemProperty -Name IncognitoModeAvailability -Path HKEY_LOCAL ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotImplemented: (:) [New-ItemProperty], PSNotSupportedException + FullyQualifiedErrorId : NotSupported,Microsoft.PowerShell.Commands.NewItemPropertyCommand PS C:WINDOWSsystem32> 

submitted by /u/infiniteapecreative
[link] [comments]

The post trying to create a registry entry and getting error appeared first on How to Code .NET.

Datanauts 136: ChatOps Using PoshBot With Brandon Olin

Use -lt to read cvs hard drive values

$
0
0

Hi,

I built a script that uses wmi to import all server values to a csv that I review each day.

The thing is that I want to automate this job so I only have to review the report with respect to monitoring drive space when the values found in the drive space column are beneath a threshold. At that point I want it to email the offending servers. I can take care of all the emailing parts.

I had some luck with this but it doesn’t appear to work right. It might have something to do with the object type not working correctly because it’s a string.

$data = import-csv servers.csv

$drives = $data.cdrive

Foreach($drive in $drives) { If([int]$drive -lt “7.0”)

 { Write-Output $drive } 

}

This works but it doesn’t give me all the offenders. What it gives me is pretty much everything below 7.50 but nothing above like 7.70.

Ideas?

submitted by /u/raider111111
[link] [comments]

The post Use -lt to read cvs hard drive values appeared first on How to Code .NET.

Viewing all 8793 articles
Browse latest View live