powershell ise
12 TopicsWindows Servers Uptime Report using PowerShell
Hi Folks, A customer has mix of Windows servers (2012, 2016, 2019) on-premises environment. Customer needs to generate a report via PowerShell about the availability of servers. During my search I found a script on this link and its modified version is attached. Please note, this script reads windows events and based on that produces result. There is a problem where I need help, this script doesn't run against list of servers via a CSV file or a text file and we suspect it is not producing correct result. Can somebody please review this script and help us with the right syntax or what is missing here? Thanks in advance.1.4KViews0likes1CommentHow to use output from 1 script in another script ??
I am trying to take the output from Script 1 and execute the actions in Script 2 against it. Script 1 = Select Device from a drop down list Script 2 = Execute option 1 or 2 against the selected Device They both work indendently but I can't figure out how to intergrate the two. Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing $form = New-Object System.Windows.Forms.Form $form.Text = 'Select a Computer' $form.Size = New-Object System.Drawing.Size(300,200) $form.StartPosition = 'CenterScreen' $okButton = New-Object System.Windows.Forms.Button $okButton.Location = New-Object System.Drawing.Point(75,120) $okButton.Size = New-Object System.Drawing.Size(75,23) $okButton.Text = 'OK' $okButton.DialogResult = [System.Windows.Forms.DialogResult]::OK $form.AcceptButton = $okButton $form.Controls.Add($okButton) $cancelButton = New-Object System.Windows.Forms.Button $cancelButton.Location = New-Object System.Drawing.Point(150,120) $cancelButton.Size = New-Object System.Drawing.Size(75,23) $cancelButton.Text = 'Cancel' $cancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel $form.CancelButton = $cancelButton $form.Controls.Add($cancelButton) $label = New-Object System.Windows.Forms.Label $label.Location = New-Object System.Drawing.Point(10,20) $label.Size = New-Object System.Drawing.Size(280,20) $label.Text = 'Please select a computer:' $form.Controls.Add($label) $listBox = New-Object System.Windows.Forms.ListBox $listBox.Location = New-Object System.Drawing.Point(10,40) $listBox.Size = New-Object System.Drawing.Size(260,20) $listBox.Height = 80 [void] $listBox.Items.Add(‘ORTECLAB001’) [void] $listBox.Items.Add('ORTECLAB002’) [void] $listBox.Items.Add('ORTECLAB003’) [void] $listBox.Items.Add('ORTECLAB004’) [void] $listBox.Items.Add('ORTECLAB005') [void] $listBox.Items.Add('ORTECLAB006') [void] $listBox.Items.Add('ORTECLAB007') [void] $listBox.Items.Add('ORTECLAB008') [void] $listBox.Items.Add('ORTECLAB009') [void] $listBox.Items.Add('ORTECLAB010') [void] $listBox.Items.Add('ORTECLAB011') [void] $listBox.Items.Add('ORTECLAB012') [void] $listBox.Items.Add('ORTECLAB013') [void] $listBox.Items.Add('ORTEC00348') $form.Controls.Add($listBox) $form.Topmost = $true $result = $form.ShowDialog() if ($result -eq [System.Windows.Forms.DialogResult]::OK) { $x = \\10.X.X.253\c$\Users\smorgan\Documents\Shutdown.ps1 $x } [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $x=args[0] $objForm = New-Object System.Windows.Forms.Form $objForm.Text = "Shutdown | Restart" $objForm.Size = New-Object System.Drawing.Size(300,300) $objForm.StartPosition = "CenterScreen" $objForm.FormBorderStyle = "FixedSingle" $objForm.KeyPreview = $True $objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape") {$objForm.Close()}}) $CancelButton = New-Object System.Windows.Forms.Button $CancelButton.Location = New-Object System.Drawing.Size(205,220) $CancelButton.Size = New-Object System.Drawing.Size(75,25) $CancelButton.Text = "Cancel" $CancelButton.Add_Click({$objForm.Close()}) $objForm.Controls.Add($CancelButton) $SButton = New-Object System.Windows.Forms.Button $SButton.Location = New-Object System.Drawing.Size(15,220) $SButton.Size = New-Object System.Drawing.Size(75,25) $SButton.Text = "Shutdown" $SButton.Add_Click({Stop-Computer -Force}) $objForm.Controls.Add($SButton) $RButton = New-Object System.Windows.Forms.Button $RButton.Location = New-Object System.Drawing.Size(110,220) $RButton.Size = New-Object System.Drawing.Size(75,25) $RButton.Text = "Restart" $RButton.Add_Click({Restart-Computer -Force}) $objForm.Controls.Add($RButton) $objLabel = New-Object System.Windows.Forms.Label $objLabel.Location = New-Object System.Drawing.Size(10,20) $objLabel.Size = New-Object System.Drawing.Size(280,120) $objLabel.Text = "Please ensure you have selected the correct LAC/E Box before proceeding." $objForm.Controls.Add($objLabel) $objForm.Topmost = $True $objForm.Add_Shown({$objForm.Activate()}) [void] $objForm.ShowDialog()2.7KViews1like1CommentRun Script from SCCM
I am a novice at PowerShell. I have a request to run a script from SCCM to install a list of printer drivers. Script is as follows... # Ricoh Universal Print Driver Get-ChildItem "\\server\d$\Print_Drivers\Ricoh\Universal Print Driver ver4_27\disk1" -Recurse -Filter "*.inf" | ForEach-Object { PNPUtil.exe /add-driver $_.FullName /install } # Ricoh SP3410dn Print Driver Get-ChildItem "\\server\d$\Print_Drivers\Ricoh\SP 3410DN\PCL6\DISK1" -Recurse -Filter "*.inf" | ForEach-Object { PNPUtil.exe /add-driver $_.FullName /install } # Ricoh SP3510dn Print Driver Get-ChildItem "\\server\d$\Print_Drivers\Ricoh\SP 3510DN\PCL6\DISK1" -Recurse -Filter "*.inf" | ForEach-Object { PNPUtil.exe /add-driver $_.FullName /install } # Ricoh SPC232dn Print Driver Get-ChildItem "\\server\d$\Print_Drivers\Ricoh\SP C232DN\PCL6\DISK1" -Recurse -Filter "*.inf" | ForEach-Object { PNPUtil.exe /add-driver $_.FullName /install } # HP T1300 Print Driver Get-ChildItem "\\server\d$\Print_Drivers\HP\T1300 PS Server 2016\win_x64_ps3_drv\win_x64_ps3_drv" -Recurse -Filter "*.inf" | ForEach-Object { PNPUtil.exe /add-driver $_.FullName /install } # Zebra ZDesigner GX420t Print Driver Get-ChildItem "\\server\d$\Print_Drivers\Other\Zebra\ZD5-1-16-7110\ZBRN" -Recurse -Filter "*.inf" | ForEach-Object { PNPUtil.exe /add-driver $_.FullName /install } I can run this script locally on a machine & it runs fine, takes about 90 seconds to complete. When I create an application for it in SCCM & deploy it, its like it doesn't have time to complete the installs before PowerShell shuts down. Then the app shows as failed in Software Center. How do I make it wait to finish running the script before closing out PowerShell?4.1KViews0likes5CommentsHybrid Exchange/O365 Automation (Off boarding)
I have been working with a script that was handed off to me. Its purpose was to automate some of our off-boarding processes on our Hybrid Exchange/Microsoft O365 server. It's worked in the past, but has been slowly breaking as time has moved on. Currently, my biggest challenge is trying to figure out why it won't let myself and a few other admins connect to our exchange/O365 server. I have a sneaking suspicion it's related to the currently installed modules/available cmdlets. The following modules are what is currently installed on my work machine; Version Name Repository Description ------- ---- ---------- ----------- 2.0.2.135 AzureAD PSGallery Azure Active Directory V2 General Availability Module.... 2.0.5 ExchangeOnlineManagement PSGallery This is a General Availability (GA) release of Exchange Online PowerShell V2 module.... 1.1.183.57 MSOnline PSGallery Microsoft Azure Active Directory Module for Windows PowerShell 1.4.7 PackageManagement PSGallery PackageManagement (a.k.a. OneGet) is a new way to discover and install software packages from around the web.... 2.2.5 PowerShellGet PSGallery PowerShell module with commands for discovering, installing, updating and publishing the PowerShell artifacts like Mod... ------------------------------------ I'm currently using; $Credentials = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session ------------------------------------- Which presents this error: New-ExoPSSession : unknown_user_type: Unknown User Type At C:\users\jbarckley\AppData\Local\Apps\2.0\RRGW2CXO.DNX\4YNQ6P50.D87\micr..tion_1f16bd4ec4c2bb19_0010.0000_673f37c317fb5976\CreateExoPSSession.ps1:302 char:30 + ... PSSession = New-ExoPSSession -UserPrincipalName $UserPrincipalName.Va ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [New-ExoPSSession], AdalException + FullyQualifiedErrorId : Microsoft.IdentityModel.Clients.ActiveDirectory.AdalException,Microsoft.Exchange.Management.ExoPowershellSnapin.NewExoPSSession ----------------------------------------------------------------------------------------------------- New-PSSession : [outlook.office365.com] Connecting to remote server outlook.office365.com failed with the following error message : For more information, see the about_Remote_Troubleshooting Help topic. At line:2 char:12 + $Session = New-PSSession -ConfigurationName Microsoft.Exchange -Conne ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException + FullyQualifiedErrorId : -2144108477,PSSessionOpenFailed Import-PSSession : Cannot validate argument on parameter 'Session'. The argument is null. Provide a valid value for the argument, and then try running the command again. At line:3 char:18 + Import-PSSession $Session + ~~~~~~~~ + CategoryInfo : InvalidData: (:) [Import-PSSession], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.ImportPSSessionCommand ---------------------------------------------------------------- Do these cmdlets only work in the EXO v1 Module? Any advice would be great!1.8KViews0likes1CommentHow to run Powershell command in Loop
Hi, I am new to Powershell script and Need your help on below requirement. I am have powershell script displaying last last 3 commands and output of my powershell script. Below last 3 command lines: $FinalResource=$FinalResource1 | Where-Object{$_.ResourceType -ne $MetricType} Write-Output $FinalResource New-AzResourceLock -LockLevel CanNotDelete -LockName Delete_Lock -ResourceName $FinalResource.Name -ResourceType $FinalResource.ResourceType -ResourceGroupName xxxxxx Below is Output of my powershell script: I am getting list of resources which are not having LOCKS on Azure after that I am applying lock on each resource by using above command. Script is running fine when I am passing single resource but script is failing when I am passing all resources. How to run last command in loop by passing one by one resource so that lock command will apply on all resources. Thanks, BrahmaSolved20KViews0likes5CommentsScript to know Access on User/Group Account
Hi Team, Is there a way to get a list of servers that user or a group has access? I am looking for a script that would give me list of servers in which that particular user or group is added to Server Local Administrators. Thanks Yash1.4KViews0likes1CommentHow to migrate selected folder and files permission from OneDrive to Sharepoint Online?
We are migrating all the permission of selected contents(files and folders) from the OneDrive to SharePoint Online, if number of files are less than 100, script migrate it's in half an hour, however, if the count of files more than 5000 then it will takes around 10 hours, which is effecting the performance of migration. Kindly find below the portion of code for getting the permissions. #$fileUrl -NewFolder/logo.png $file = Get-PnPFile -Url $fileUrl -AsListItem Get-PnPProperty -ClientObject $file -Property RoleAssignments $members = Get-PnPProperty -ClientObject $roleAssignments -Property RoleDefinitionBindings, Member $member = $roleAssignments.Member #list of users $Users = Get-PnPProperty -ErrorAction SilentlyContinue -ClientObject $member -Property Users #Return Accesstype $accessType = $roleAssignments.RoleDefinitionBindings.Name; Hence, we are decide to use workflow in the PowerShell script, as shown in the below link: https://gist.github.com/jamiekt/f586e47cb96b93dacbe5 But this link doesn't fulfil our requirement. Kindly let us any suitable solution in the PowerShell to meet our requirement895Views0likes0CommentsCannot convert the "Microsoft.SharePoint.Client.ListItem" value of type "Microsoft.SharePoint.Clien
When we run the below script on the Power shell version 5.1 for fetching file property. workflow IterateWorkflow { Parallel { Connect-PnPOnline -Url $SrcFolderURL -Credentials $creds -ErrorAction SilentlyContinue -WarningAction SilentlyContinue $folderUrl = "/Documents/It's a level 3 folder for testing/Level 4/file-sample_100kB.doc" $file = Get-PnPFile -Url $folderUrl -AsListItem if ($file) { Get-PnPProperty -ClientObject $file -Property HasUniqueRoleAssignments, RoleAssignments } else { $file = Get-PnPFile -Url $folderUrl -AsListItem Get-PnPProperty -ClientObject $file -Property HasUniqueRoleAssignments, RoleAssignments } } } We are getting Microsoft related issue, however, its running successful on non-workflow the Power Shell. Cannot bind parameter 'ClientObject'. Cannot convert the "Microsoft.SharePoint.Client.ListItem" value of type "Deserialized.Microsoft.SharePoint.Client.ListItem" to type "Microsoft.SharePoint.Client.ClientObject"2.6KViews0likes0CommentsPowerShell ISE is a blank white on black Window after update to Windows 10 Version 1903
Powershell ISE is not working on my Windows 10 laptop, not sure when this happened but i am just updated to Version 1903. Does anyone know how to fix this problem, I have attached an image showing how the ISE looks, see below. This is very annoying, Help! B6.5KViews1like4Comments