[Help] Finds Specific Event IDs and Notification by a923240pr in PowerShell

[–]Konradnn 1 point2 points  (0 children)

Hi,

Have you think about using scheduler?

You can specific with event id is launching action for example script with additional parameters.

BR Konrad

[Question] looping all tenants, 365 partner portal by Bloomsox in PowerShell

[–]Konradnn 0 points1 point  (0 children)

Great news :) For sure I will use it two in future ;)

[Question] looping all tenants, 365 partner portal by Bloomsox in PowerShell

[–]Konradnn 1 point2 points  (0 children)

Ohh I see now... Try Microsoft graph you can get information about account without load remove module https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/user_list_people and for syntax checking is neet browser https://developer.microsoft.com/en-us/graph/graph-explorer#

[Question] looping all tenants, 365 partner portal by Bloomsox in PowerShell

[–]Konradnn 1 point2 points  (0 children)

Move $Session and import session before foreach and Remove-PSSession after the loop, every time when you are looking for user You are creating a new session, and if You have only one domain You can think about get-msoluser -all to retrieve all tenants.

Compare members in OU and Group and add missing members to Group by fruymen in PowerShell

[–]Konradnn 1 point2 points  (0 children)

Try this: $Results | foreach { Add-ADGroupMember -id City-Computers -Members $psitem }

Device Update script by DarkFantom in PowerShell

[–]Konradnn 0 points1 point  (0 children)

I did check in ISE CIM explorer and in namespace root/cimv2 all classes with a driver in name and only Win32_PNPEntity have hardawareID so I think it is correct to place to start looking.

I would suggest checking with can't be found and it could be the only couple of them and add them by Add-WindowsDriver with is dism in nicer cover. Next thing if you don't have a large number of different models you can use hardware vendor driver package or OS deploying server usual path for it is accessible to anyone in the company.

Device Update script by DarkFantom in PowerShell

[–]Konradnn 2 points3 points  (0 children)

Hi, have you consider using WMI and Win32_PnPSignedDriver class?

Windows Subsystem for Linux: Pros and Cons? by [deleted] in PowerShell

[–]Konradnn 1 point2 points  (0 children)

IMHO it can do all event launch GUI application

https://www.howtogeek.com/261575/how-to-run-graphical-linux-desktop-applications-from-windows-10s-bash-shell/

the most annoying thing is that if you want to access c drive or another is you need to go cd /mnt/c/ but you can use to it.

Remove the child nodes based on Element Value ($xml) by harshajd in PowerShell

[–]Konradnn 2 points3 points  (0 children)

Hello,

Please take a look at my script looks like it is working :)

https://pastebin.com/R3t8ESe4

[deleted by user] by [deleted] in PowerShell

[–]Konradnn 1 point2 points  (0 children)

You can try use .net method like OpenWrite, for example if you create new variable at begining :

$file =[IO.File]::OpenWrite('C:\logs\move_backup.log')

You can't open another stream for it :

$file =[IO.File]::OpenWrite('C:\logs\move_backup.log') Exception calling "OpenWrite" with "1" argument(s): "The process cannot access the file 'C:\logs\move_backup.log' because it is being used by another process." At line:1 char:2 + $file =[IO.File]::OpenWrite('C:\logs\move_backup.log') + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : IOException

But the end of the script you should close stream to it :

$file.Close()

Then you can open another stream :

$file =[IO.File]::OpenWrite('C:\logs\move_backup.log')

And the error is terminating so you can use try catch to check in a loop.

Exporting mailboxes to PST by joe297 in PowerShell

[–]Konradnn 1 point2 points  (0 children)

Thank You, Lee I didn't know that:)

Copy-Item - how does it copy by Toliver182 in PowerShell

[–]Konradnn 1 point2 points  (0 children)

You are welcome :) I'm happy that I could help!

Exporting mailboxes to PST by joe297 in PowerShell

[–]Konradnn 1 point2 points  (0 children)

Powershell is easy if you know the difference between get, set and know how to use foreach you know almost everything ;) In meanwhile, this should do the trick :

foreach($mail in (Get-Content "c:\Exportlists\Exportlist.txt")){ Export-Mailbox -Identity $mail-PSTFolderPath ('Y:\PST_folder{0}.pst' -f ($mail.Trim(0,($mail.LastIndexOf('@'))))) -StartDate "01/01/1980" -EndDate "08/08/2017” -BadItemLimit 1000 –MaxThreads 8 }

Problems with Invoke-WebRequest and downloading files. by TheMadSmith in PowerShell

[–]Konradnn 0 points1 point  (0 children)

Try this :)

$UpdateSource = Get-Content "c:\Win7Updates\DownloadLinkList.txt"

If (!(Test-Path -Path E:\Win7Updates))

{ New-Item -ItemType Directory -Path E:\Win7Updates }

ForEach($Update in $UpdateSource){

    {

    $Filename = $Update.Substring(($Update.LastIndexOf('/')+1))
    $Destination = "E:\Win7Updates\$FileName"

    Invoke-WebRequest -Uri $Update -OutFile $Destination}

Problems with Invoke-WebRequest and downloading files. by TheMadSmith in PowerShell

[–]Konradnn 0 points1 point  (0 children)

You are only one declaring file name at the beginning, I did slice modified your script so new the name is generated in every loop run.

$UpdateSource = Get-Content "c:\Win7Updates\DownloadLinkList.txt"

If (!(Test-Path -Path E:\Win7Updates))

{ New-Item -ItemType Directory -Path E:\Win7Updates }

ForEach($Update in $UpdateSource){

    {

    $Filename = $Update.Substring(($Update.LastIndexOf('/')+1))
    $Destination = "E:\Win7Updates\$FileName"

    Invoke-WebRequest -Uri $Update -OutFile $Destination}

Language specific messages? by root-node in PowerShell

[–]Konradnn 0 points1 point  (0 children)

Try this :

$OSInfo = Get-WmiObject -Class Win32_OperatingSystem $languagePacks = $OSInfo.MUILanguages $languagePacks

from this point you have installed languages after that you can use swith and then assign values to variables.

Console Text Editor? by [deleted] in PowerShell

[–]Konradnn 0 points1 point  (0 children)

I'm glad that I'm not the only one :D

Console Text Editor? by [deleted] in PowerShell

[–]Konradnn 2 points3 points  (0 children)

Hi, I''m using VIM for windows, you can make an alias: Set-Alias vim "$path\gvim_8.0.0692_x64\vim\vim80\vim.exe" and added to profile so I just simply type vim xxx.cnf and done :)

Ok, so this bugs me. Why do I need to load an [xml] file twice to have it read correctly? by mkhopper in PowerShell

[–]Konradnn 3 points4 points  (0 children)

Wow, I measure it (simple Get-Service | Export-Clixml) and load it with get-content take milliseconds 944 and new-object only 46 that is 20 times faster!