Jump to content

Jay9xx

Members
  • Posts

    11
  • Joined

  • Last visited

Everything posted by Jay9xx

  1. Cool beans! I will give it a look. That has been something I've been needing to learn about as well. I haven't had a chance to play around with the graph API stuff yet. It will be cool to see! Jay
  2. Awesome. I definitely will keep that in mind. Everyday is a new learning experience with powershell. So much you can accomplish with it.
  3. I feel kinda dumb now. I found out what was going on and why I wasn't seeing things after I ran them in a script. Apparently I think that is how it is supposed to work. My mistake was piece milling it together instead of just trying to run all of it at once. When I would run the script, and then try to use the cli to get values for the variables using the echo command, apparently anything ran inside the script environment stays within that environment and doesn't propagate to the open command line, if that makes sense? For example I could run the script you helped me with, then expect to issue "echo $MSOusers" and see the value for $MSOusers but it wouldn't show up at all. But if I included the echo MSOusers in the script, it would produce the output I was looking for after I ran the script showing "[email protected]". So I went ahead and put the rest of my script together and it worked fine. Wasn't sure if you knew that or not, but in case not I wanted to let you know what was happening and thanks again for all the help. This script will go a long way to help automate a task that has been a bit of a pain lately.
  4. Never mind. It seems to be working now. I think my text editor was putting in some strange characters causing it to be off. Cool beans I should be able to get it from here ...maybe..hehe. I really do appreciate your time and help with the syntax on this.
  5. $ADUsers=Get-ADUser -Filter {extensionAttribute6 -like "TESTATT"} | select UserPrincipalName $ADUsers.UserPrincipalName.ForEach({$MSOusers=Get-msoluser -userprincipalname $_ |where-object{$_.Licenses.AccountSkuId-eq "domain:STANDARDWOFFPACK_STUDENT"} > .\usersmso.txt }) The last part > .\usersmso.txt I'm just using to test output when running using a .bat file calling powershell. But it works when ran separately still though.
  6. Ok, my bad it does work as long as I don't run the first line in the same script. If I run the first line, then run the line next separately it is reporting correctly and I see [email protected] output that I should see. Really strange. For some reason, if I put both in the same script, I get a null value for $ADUsers, so that is why I was getting nothing for $MSOusers previously. Not sure if there is something I can do to get them to work in the same script though.
  7. Ok, the script didn't error out this time, but it's not returning any users. I currently have two users set that the first line should feed back and it does. Basically if I do "echo $ADUsers.userprincipalname" I will see the following. [email protected] [email protected] But after I run the next part now, I'm not getting any errors at all, but when I run the last part, it should only showing me [email protected], as [email protected] doesn't match the license criteria I have set at the end part of the script. That is assuming that I should be able to do "echo $MSOUsers" and see either the UPN or details for [email protected] who does match the license criteria I have set at the last part of the script. Maybe?
  8. Cool beans HPlum! Really appreciate the help with this. I'll try and get back soon!
  9. Getting the error below now. You mentioned a later version of powershell. What version should this work on? That could by my problem. I'm running 5.1.19041.1. Get-MsolUser : Cannot bind argument to parameter 'UserPrincipalName' because it is null.At C:\temp\msousers.ps1:4 char:43+ ... ers=Get-msoluser -userprincipalname $ADUser.userPrincipalName |where- ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: ( [Get-MsolUser], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.Online.Administration.Automation.GetUser
  10. I tried that at first, because I didn't want to pull the -filter * and -properties *, but for some reason it wasn't capturing the extensions attribute unless I did that. Not sure what was up with that, but to your credit I thought for the hell of it I'll try it again and now it is freaking working, but I used the -eq instead of -notlike. So thanks for bringing that back up. The cleaner I can make the powershell the better. But however that still has no bearing on fixing the problem at hand unfortunately.
  11. Trying to run the script below to filter out users to input into another script. $ADUsers = Get-ADUser -filter * -Properties * | ? {$_.extensionAttribute6 -eq "TESTATT"} Foreach ($ADUser in $ADUsers) { $MSOusers = Get-msoluser -userprincipalname $ADUser.userPrincipalName | where-object {$_.Licenses.AccountSkuId -eq "mydomain:STANDARDWOFFPACK_STUDENT"} } The first line runs correctly and will output the correct results if I echo them out in the format below. [email protected] [email protected] When I get to the next part (Foreach) I get the error I posted in the subject below. Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'UserPrincipalName'. Specified method is not supported. Any suggestions on what I'm doing wrong or lacking in the script?
×
×
  • Create New...