Quantcast
Channel: Windows PowerShell forum
Viewing all 21975 articles
Browse latest View live

Disk usage % is not displaying other than Default OS drive

$
0
0

Hi,

I am new to PS Scripting

I have downloaded the script "Powershell Script to Get CPU,Memory and Drive utilization(Server Health Check)" from https://gallery.technet.microsoft.com/scriptcenter/Powershell-Script-to-Get-78687c5e

Script works and shows the result as expected , but It only shows the details of default OS drive only that is C:

I have modified the script so it can show the % details other drives as well, can someone suggest.

I have added below to default script

$vol = Get-WmiObject -Class win32_Volume -ComputerName $computername -Filter "DriveLetter = 'C:'" | 
Select-object @{Name = "C PercentFree"; Expression = {“{0:N2}” -f  (($_.FreeSpace / $_.Capacity)*100) } } 

$vol = Get-WmiObject -Class win32_Volume -ComputerName $computername -Filter "DriveLetter = 'D:'" | 
Select-object @{Name = "D PercentFree"; Expression = {“{0:N2}” -f  (($_.FreeSpace / $_.Capacity)*100) } } 

------

CDrive = "$($vol.'C PercentFree')%" 
DDrive = "$($vol.'D PercentFree')%"

----------

<TD><B>C Drive Utilizatoin</B></TD>
<TD><B>D Drive Utilizatoin</B></TD>

--------

</TD><TD align=center>$($Entry.Cdrive)
 </TD><TD align=center>$($Entry.Ddrive)

-------------------

screenshots for reference

-Atul A


TheAtulA


Extract licensed user with active mailbox status

$
0
0

Hi,

May I ask for assistance how can I extract users that have exchange mailbox+licensed and its mfa status.

BlockedCredentials,Displayname,FirstName,Lastname,Whencreated,last login,MFA status,Islicensed especially for exchange only.

Best Regards,

Mark

convert .eml to .msg

$
0
0

I have 500000 .eml files that needs to be converted to .msg file and save in local folder.

I want to know if we have any powershell command to do so?

Or any other efficient method to achieve this??(C#)

PS: Dont want to use third party converters.

Run Macro with dynamic parameter

$
0
0

I'm trying to execute some macros though my powershell in a dynamic way. I receive a dictionary with macro names and parameters and try to call the macros and execute it. 

It is giving me the following error:

System.Management.Automation.MethodInvocationException: Exception calling "Run" with "4" argument(s): "Number of parameters specified does not match the expected number." ---> System.Reflection.TargetParameterCountException: Number of parameters specified does not match the expected number.


This is the code.

function Quote-Param([object[]] $param) {
	#put quotes into the parameters unless they are numeric
	[decimal] $number = 01
	foreach ($p in $param) {
		if ([decimal]::TryParse($p, [ref]$number)) {$p} else {('"{0}"' -f $p) }
	}

}

$xl = new-Object -comObject excel.application
#Show Excel
$xl.visible = $Visible
$xl.DisplayAlerts = $false
# Open Excel file	
$workbook = $xl.Workbooks.Open("C:\Excel.xlsm",0,0,5,"password")

$ListMacros = @{"Macro1" = "Param1#Param2#Param3"	;"Macro2"=""	;"Macro3"=""}


Foreach ($key in $ListMacros.GetEnumerator()) {

    $arguments = @(Quote-Param $key.Name)
    $arguments += Quote-Param $key.Value.Split("#")
    $arguments = $arguments -join ','  

    $xl.run.Invoke($arguments)

}

If in the line 

$xl.run.Invoke($arguments)

I pass:

$xl.run.Invoke("Macro1", "Param1", "Param2" , "Param3")

It works.

Do you have any experience on this?

Thank you in advance.

scripts runs on commandline but no longer from task scheduler

$
0
0

Hi,

I have a script that connects to office365 to download some log info from yesterday and save it in a file. This script used to run fine.

Then April 17th I had to change the password on Office365 and so I changed the info in the encrypted password file.
In case it is relevant, I create the password file with this little script:

Read-Host "Enter Password for xxx@hogeschooltio.onmicrosoft.com" -AsSecureString |  ConvertFrom-SecureString | Out-File "C:\Scripts\PWXXXO365.txt"

Logged on as the local administrator, so no connection to the O365 account, the script getting the log info still runs perfectly if I run it in a Powershell command window. However, running the taskscheduler to run the scrip I now get a result code 0x103 when the script gets terminated after the 2h timeout (script usualy runs within one minute).

I added some debug lines an it seems it never gets to step 3

-----

Write-Output "step 1" | Out-File -FilePath C:\Temp\test.txt
$User = "xxx@hogeschooltio.onmicrosoft.com"
$PWFile = "C:\Scripts\PWXXXO365.txt"
$cred=New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, (Get-Content $PWFile | ConvertTo-SecureString)

Write-Output "step 2" | Out-File -Append -FilePath C:\Temp\test.txt
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $cred -Authentication Basic –AllowRedirection
Import-PSSession $Session

Write-Output "step 3" | Out-File -Append -FilePath C:\Temp\test.txt

-----

So what is so special about those 2 lines after  "Step 2" and before "step 3" that it will run in a simple commandline but not from a taskscheduler? And remember this ran OK before changing the password file to the current password, so it might be related to that. But if the password is wrong why would it run correctly from the commandline?

This is running on a Windows 2016 server. Powershell version:
PS C:\Scripts> $PSVersionTable


Name                           Value
----                           -----
PSVersion                      5.1.14393.2791
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.2791
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Exchange PowerShell

$
0
0
Hi All,

We want to search e-mail in our all mailboxes then export e-mails by a specific from e-mail address and receiptent e-mail address
I mean, we want to find all e-mails  from x@sender.com and y@receiptent.com then export the mails.

Simple question data import in AD

$
0
0

Hi) I'm a beginner of PowerShell and I love microsoft products. Pls help me.

I'm trying to set business position  from a csv file to Active Directory base. 


My csv file has the following view :

Position Name

 XXX       XXX

The Name from csv file field is the last name and matches the Surname of object in active directory property

I do the following:

Import-Csv D:\PS\UsersEdit.ru.en_test.csv -Delimiter ";" | ForEach-Object { Get-ADUser -Filter { Surname -eq $_.Name} | Set-ADUser -Title $_.Position}

What am I doing wrong? help me please


send powershell output to sql server table

$
0
0
Function CleanUp-PSDrive {
    Get-PSDrive -PSProvider FileSystem | Where { $_.Name -in (69..90 | ForEach-Object { [char]$_ })} | Remove-PSDrive
}

$Csv = Import-Csv "path"   

$Csv.Name | ForEach-Object -Begin { $Letter = 69 } {

 new-PSDrive -Root  $_ -Name([char]$Letter) -PSProvider FileSystem -Persist 
 
   if ($Letter -lt 90) 
    { 
      $Letter++ 
    } 
    else 
    { 
        CleanUp-PSDrive
        $Letter = 69
    }
} -End { CleanUp-PSDrive } | 
  Select-Object  @{name="File Share Name";expression={$_.'DisplayRoot'}}, @{name="Total(GB)";expression={[math]::Round(($_.free+$_.used)/1GB,2)}}, @{name="Used(GB)";expression={[math]::Round($_.used/1GB,2)}}, @{name="Free(GB)";expression={[math]::Round($_.free/1GB,2)}}, @{name="Total(%)";expression={[math]::Round($_.used/($_.used+$_.free)*100,2)}}, @{name="Date";expression={(Get-Date).ToString('MM-dd-yyyy')}} | 
  Write-SqlTableData -serverinstance "usalbsqldev002.logon.ds.ge.com\dev002" -DatabaseName "FileShare" -SchemaName "dbo" -TableName "New1" -force


Send mail authentication

$
0
0

Hi,

To start off I'm very inexperienced with powershell.  I've been working on a command to put in a batch job to pull some data from ADLDS.  I've figured out the command I need which is something like this.

Get-ADUser -Filter {description -eq "app2"} -SearchBase 'CN=Users,CN=WAP,DC=domain,DC=COM' -Properties DisplayName,lastlogontimestamp,description -Server localhost:389 | select Name, description| export-csv C:\temp\Final.csv -NoTypeInformation
Send-MailMessage -From 'Shannon <me@me.org>' -To 'Suhail <me@me.org>' -Subject 'Testing' -Credential me\me -SmtpServer 'me.me.org' -Attachment "C:\temp\Final.csv"

It works.  However, when I run it in the powershell window, a windows authentication window pops up for my password.  So two things.  1 I need to put the password in their as well, which i'm sure isn't hard, but 2. I don't want usernames and password inside a script, that's like bad mojo.

The -usessl throws a certificate error.

Thanks!

Powershell type conversion problems

$
0
0

I've a very annoying issues, when using types in Powershell. I'm automating the process to create virtual machines in Hyper V. I want to use the correct type in and out of functions to have validation on parameters. When I create a VM, i normally get an object of type [Microsoft.HyperV.PowerShell.VirtualMachine]. Sometimes though, I get an array of what looks like [PSCustomObject], with the correct attributes. When I try to convert this to [Microsoft.HyperV.PowerShell.VirtualMachine], I get the following error:

Cannot convert the "VirtualMachine (Name = 'VM0002') [Id = 'f58a6dc0-fd21-44f3-a7de-01998283f69e']" value of type "Microsoft.HyperV.PowerShell.VirtualMachine" to type "Microsoft.HyperV.PowerShell.VirtualMachine".
At HypervisorManager.psm1:330 char:9
+         [Microsoft.HyperV.PowerShell.VirtualMachine]$vm = Get-VM -Nam ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : MetadataError: (:) [], ArgumentTransformationMetadataException
    + FullyQualifiedErrorId : RuntimeException

When i run the following, I get a $false: (Get-VM VM0002) -is [Microsoft.HyperV.PowerShell.VirtualMachine]

When I run the following, it looks, like the type is korrekt: $vm = Get-VM VM0002; $vm.gettype()

What am I'm not understanding?

Additional Info:
Tested this on Server 2016 with Hyper V.

The same commands return the correct type, as expected, on Windows 10 Hyper V.

AD attribute query - Need some help

$
0
0

First let me say that I have almost no experience with powershell.  I know how to dump some code in to a .ps1 file to be run like a batch file.  Here is what I'm trying to figure out.

We're going to be using an ADLDS attribute, "Description", to add data for which type of application someone uses on our site, and separate those applications with semi colons.

Example app1;app2;app3

I need a script that will read this attribute and parse those apps in to variables, then execute something based on the variable.

Example: I need to see if a user has app2 in the user account description field, see if their account is enabled, and if their account is enabled, , pull them in to a csv file, then email that file to a distribution list. 

So I end up with a csv file listing how many users have app1 or app2.

Any help is greatly appreciated.

here is a script that seems to work to pull some of that data from ADAM.

Get-ADObject -Server 'localhost:389' -SearchBase 'CN=Users,CN=WAP,DC=domain,DC=COM' -Filter 'description -like "*"' -properties DisplayName,lastlogontimestamp, description | select Name, description, `
        @{Name="LastLogonTimeStamp";Expression={([datetime]::FromFileTime($_.LastLogonTimeStamp))}},`
    @{Name="pwdLastSet";Expression={([datetime]::FromFileTime($_.pwdLastSet))}} | export-csv c:\temp\userauditlast4.csv -NoTypeInformation

This also pulls last logon timestamp, and last time password reset, which I really don't need.

Error exporting PLANNER data

$
0
0

Hi all,

I am trying to export all PLANNER data due to a Tenant migration that is about to happen in the near future. So far I managed to export some users using the following Powershell code:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
Import-module "C:\PlannerUserContentExport\plannertenantadmin.psm1"
Export-PlannerUserContent -UserAadIdOrPrincipalName account-name@domain-name.com -ExportDirectory C:\PlannerExport

This last line repeats itself for all users. However, for some users I am getting the following error:

We couldn´t start your export. Error message: The remote server returned an error: (401)

Unauthorized. Support information: CorrelationId 02e15510-6d3e-4280-876b-424046f41335 At C:\PlannerUserContentExport\plannertenantadmin.psm1:164 char:9

+throw $exceptionToThrow

+CategoryInfo: NotSpecified:  (:) [], ParentContainsErrorRecordException

+FullyQualifiedErrorId

Any help is aprreciated.

Best regards,

Mario

validate read-host to yes or no

$
0
0

I want to use read-host, but I only want the input to be yes or no.

How do I achieve this?

Writing NETGUID value to computer object attribute field for computers in group (using Powershell)

$
0
0
I am learning powershell and I need to write the NETBOOTGUID value to computer object attribute field for computers in a given AD group.

The pwersheelscript below is working partially.

It gets succesfully the NETGUID VALUE from computers online at the time the script is ran, but is writing the SAME NETBOOTGUID value   on all computers on the given group.

 

So I suspect my code is wrong somewhere in the ForEach-Object.  Can anyone help? Thanks.


Import-Module ActiveDirectory

# Get all members of the MP-W-Test-Netguid

  Get-ADGroupMember 'MP-W-Test-Netguid' |
    # Loop through each object


   ForEach-Object {
        # Do this for each member

 # $guid = [guid](Get-WmiObject Win32_ComputerSystemProduct).UUID

  $guid = [guid](Get-CimInstance -Classname Win32_ComputerSystemProduct).UUID 

Set-ADComputer -Identity $_.SamAccountName -Replace @{ netbootGUID = $guid.ToByteArray() }

}

Unable to get the used space and free space using the new-psdrive command. I am using the below code. The code is running without error but not getting the used space and free space of the disk

$
0
0
Function CleanUp-PSDrive {
    Get-PSDrive -PSProvider FileSystem | Where { $_.Name -in (69..90 | ForEach-Object { [char]$_ })} | Remove-PSDrive
}

$Csv = Import-Csv "Path"

$Csv.Name | ForEach-Object -Begin { $Letter = 69 } {

 New-PSDrive -Root  $_ -Name([char]$Letter) -PSProvider FileSystem 




 
 

    if ($Letter -lt 90) 
    { 
      $Letter++ 
    } 
    else 
    { 
        CleanUp-PSDrive
        $Letter = 69
    }
} -End { CleanUp-PSDrive } | select used,free | export-csv "Path" -NoTypeInformation

Powershell Form Change Text Box Size

$
0
0

I am trying to resize a textbox and set multiline to true when a certain option is selected within a listbox above.  Weird thing is that when I right click my script, select edit, and then run it using the editor it works but when I call the file in powershell directly on the same machine it does not.  I have included the form below.  Can anyone tell me what I am doing wrong?

#begin to draw forms
$Form = New-Object System.Windows.Forms.Form
$Form.Text = "Email Creator Tool"
$Form.Size = New-Object System.Drawing.Size(315,205)
$Form.StartPosition = "CenterScreen"

$Form.KeyPreview = $True
$Form.Add_KeyDown({if ($_.KeyCode -eq "Escape")
{$Form.Close()}})

$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Size(5,5)
$label.Size = New-Object System.Drawing.Size(295,65)
$label.Text = "Enter the Employee ID or Username for the user you wish to make changes to.  Then select the field you wish to change and enter the value in the fields below.  The script will send your request to the server and you will recieve email confirmation of changes made."
$Form.Controls.Add($label)

$label2 = New-Object System.Windows.Forms.Label
$label2.Location = New-Object System.Drawing.Size(5,72)
$label2.Size = New-Object System.Drawing.Size(75,20)
$label2.Text = "Employee ID:"
$Form.Controls.Add($label2)

$textbox = New-Object System.Windows.Forms.TextBox
$textbox.Location = New-Object System.Drawing.Size(80,72)
$textbox.Size = New-Object System.Drawing.Size(135,20)
#$textbox.Text = "Employee ID"
$Form.Controls.Add($textbox)

$label3 = New-Object System.Windows.Forms.Label
$label3.Location = New-Object System.Drawing.Size(5,92)
$label3.Size = New-Object System.Drawing.Size(75,20)
$label3.Text = "UserName:"
$Form.Controls.Add($label3)

$textbox2 = New-Object System.Windows.Forms.TextBox
$textbox2.Location = New-Object System.Drawing.Size(80,92)
$textbox2.Size = New-Object System.Drawing.Size(135,20)
#$textbox2.Text = "UserName"
$Form.Controls.Add($textbox2)

$label4 = New-Object System.Windows.Forms.Label
$label4.Location = New-Object System.Drawing.Size(5,120)
$label4.Size = New-Object System.Drawing.Size(75,20)
$label4.Text = "Field:"
$Form.Controls.Add($label4)

$listbox3 = New-Object System.Windows.Forms.listbox
$listbox3.Location = New-Object System.Drawing.Size(80,112)
$listbox3.Size = New-Object System.Drawing.Size(135,40)

[void] $ListBox3.Items.Add("Office")
[void] $ListBox3.Items.Add("Direct")
[void] $ListBox3.Items.Add("Fax")
[void] $ListBox3.Items.Add("Title")
[void] $ListBox3.Items.Add("Notes")
$ListBox3.add_SelectedIndexChanged($listbox3_SelectedIndexChanged)

$Form.Controls.Add($listbox3)

$label5 = New-Object System.Windows.Forms.Label
$label5.Location = New-Object System.Drawing.Size(5,145)
$label5.Size = New-Object System.Drawing.Size(75,20)
$label5.Text = "Value:"
$Form.Controls.Add($label5)

$textbox4 = New-Object System.Windows.Forms.TextBox
$textbox4.Location = New-Object System.Drawing.Size(80,142)
$textbox4.Size = New-Object System.Drawing.Size(135,20)
#$textbox4.Text = "Value"
$textbox4.Multiline = $false
$Form.Controls.Add($textbox4)

$listbox3_SelectedIndexChanged={
    If ($listbox3.SelectedItem -eq "Notes") {
        write-host Notes
        $textbox4.Size = New-Object System.Drawing.Size(135,40)
        $textbox4.Multiline = $true
        $textbox4.refresh
        $form.refresh
    } Else {
        write-host Not Notes
        $textbox4.Size = New-Object System.Drawing.Size(135,20)
        $textbox4.Multiline = $false
        $textbox4.refresh
        $form.refresh
    }
}

$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(220,70)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = "OK"
$OKButton.Add_Click({create-accounts $textbox.Text $textbox2.Text $listbox3.Text $textbox4.Text;$textbox.Text="";$textbox2.Text="";$listbox3.Text="";$textbox4.Text=""})
$Form.Controls.Add($OKButton)

$Form.Topmost = $True
$Form.Add_Shown({$Form.Activate()})
[void] $Form.ShowDialog()

Powershell loop to cast value to variable from multiple possible sources

$
0
0

Hi,

I'm struggling to work out the logic in this one. I need to query 3 or four sources for a particular value and cast the first resultt into a variable and cannot figure out how to do this.

I am looking for a users Manager and it could be stored in three different value locations. This should give some idea:-

        DO
            {
            $manager = (get-aduser $user.LINE_MANAGER -Properties Displayname).displayname
            $manager = (get-aduser $user.ADDITIONAL_LINE_MANAGER -Properties Displayname).displayname
            $manager = (get-aduser $aduser.manager -Properties Displayname).displayname
            $manager = "No Line Manager Specified"
            }
        While ( $manager -eq $null)
So I want the loop to query the sources until it finds a value and passes that into the $manager variable the break out the loop. I've thought about doing an If = $null function on each line, but it seems clumsy. Any pretty way of doing this?

Parameter value not being received by scriptblock

$
0
0

I have powershell file which uses a script block which i am calling for executing code remotely, what i am finding is that the values are not being passed onto the scriptblock.  

When I call the file and pass the parameters, they are coming up as blank within the scriptblock write-verbose command.

Param 
(
	[Parameter(Mandatory=$true)]	[string] $ServerName,
	[Parameter(Mandatory=$true)]	[string] $d_size,
	[Parameter(Mandatory=$true)]	[string] $root_size,
	[Parameter(Mandatory=$true)]	[string] $data_size,
	[Parameter(Mandatory=$true)]	[string] $log_size,
	[Parameter(Mandatory=$true)]	[string] $sys_size,
	[Parameter(Mandatory=$true)]	[string] $tempdb_size,
	[Parameter(Mandatory=$true)]	[string] $backup_size

)
#[CmdletBinding]



$scriptblock = 
    {

        $d_size = $d_size.ToString() + "GB"
        $root_size = $root_size.ToString() +"GB"
        $data_size = $data_size.ToString() + "GB"
        $log_size = $log_size.ToString()+"GB"
        $sys_size = $sys_size.ToString()+"GB"
        $tempdb_size = $tempdb_size.ToString()+"GB"
        $backup_size = $backup_size.ToString()+"GB"

        write-host "The root size is $root_size and D = $d_size and data = $data_size and log = $log_size and sys =  $sys_size and tempdb =  $tempdb_size and backup =  $backup_size "


}

invoke-command -ComputerName $ServerName -Credential $credential -Scriptblock $scriptblock -ArgumentList $d_size,$root_size,$data_size,$log_size,$sys_size,$tempdb_size,$backup_size

Also what is the best way to pass such parameters, in some cases I can have up to 20 parameters.

Thanks in advance.


The workflow definition has been recycled, because the workflow definition cache limit of 1000 has been reached

$
0
0

Hi all,

We are experiencing a issue executing a long powershell processes. We get this message:

The workflow definition has been recycled, because the workflow definition cache limit of 1000 has beenreached

This occurs after October 2018 patch in Windows 2016 Datacenter Server edition. For a while was possible uninstall this patch but now, after December update, isn't possible do this.

There is a workaround but don't work.

Are there any related issue?

Regards,

Eduard.


Resize form and its controls

$
0
0

Hi guys, I need to resize this form, because in screens with very high resolutions everything is too small.
Can you tell me how to resize all the objects in it?

cls

$width = 1120
$Height = 560

$Form = New-Object System.Windows.Forms.Form    
$Form.Size = New-Object System.Drawing.Size($LarghezzaForm,$AltezzaForm)
$Form.MaximizeBox = $True
$Form.minimumSize = New-Object System.Drawing.Size($LarghezzaForm,$AltezzaForm) 
$Form.maximumSize = New-Object System.Drawing.Size(2120,1560) 
$Form.StartPosition = "CenterScreen"

$imagelistPC = New-Object 'System.Windows.Forms.ImageList'
$listviewPC = New-Object System.Windows.Forms.ListView
$listviewPC.Location = New-Object System.Drawing.Point(20,125) 
$listviewPC.Size = New-Object System.Drawing.Size(585,180) 
$form.Controls.Add($listviewPC) 

$button1user = New-Object System.Windows.Forms.Button 
$button1user.Location = New-Object System.Drawing.Size(625,30) 
$button1user.Size = New-Object System.Drawing.Size(110,40)
$button1user.Cursor = [System.Windows.Forms.Cursors]::Hand
$button1user.Font = New-Object System.Drawing.Font('Microsoft Sans Serif', 7, [System.Drawing.FontStyle]::Regular)
$button1user.Text = "test1" 
$button1user.BackColor = "Yellow"
$button1user.Add_Click({test1}) 
$Form.Controls.Add($button1user)  

$button2user = New-Object System.Windows.Forms.Button 
$button2user.Location = New-Object System.Drawing.Size(625,80)
$button2user.Size = New-Object System.Drawing.Size(110,40)
$button2user.Cursor = [System.Windows.Forms.Cursors]::Hand
$button2user.Font = New-Object System.Drawing.Font('Microsoft Sans Serif', 7, [System.Drawing.FontStyle]::Regular)
$button2user.Text = "test2" 
$button2user.BackColor = "Yellow"
$button2user.Add_Click({test2}) 
$Form.Controls.Add($button2user)  

$button3user = New-Object System.Windows.Forms.Button 
$button3user.Location = New-Object System.Drawing.Size(625,130) 
$button3user.Size = New-Object System.Drawing.Size(110,40)
$button3user.Cursor = [System.Windows.Forms.Cursors]::Hand
$button3user.Font = New-Object System.Drawing.Font('Microsoft Sans Serif', 7, [System.Drawing.FontStyle]::Regular)
$button3user.Text = "test3" 
$button3user.BackColor = "Yellow"
$button3user.Add_Click({test3})
$Form.Controls.Add($button3user) 

$button1pc = New-Object System.Windows.Forms.Button 
$button1pc.Location = New-Object System.Drawing.Size(745,30) 
$button1pc.Size = New-Object System.Drawing.Size(110,40)
$button1pc.Cursor = [System.Windows.Forms.Cursors]::Hand
$button1pc.Font = New-Object System.Drawing.Font('Microsoft Sans Serif', 7, [System.Drawing.FontStyle]::Regular)
$button1pc.Text = "test A" 
$button1pc.BackColor = "Yellow"
$button1pc.Add_Click({COMPUTERCHANGEOU}) 
$Form.Controls.Add($button1pc)  

$button2pc = New-Object System.Windows.Forms.Button 
$button2pc.Location = New-Object System.Drawing.Size(745,80) 
$button2pc.Size = New-Object System.Drawing.Size(110,40)
$button2pc.Cursor = [System.Windows.Forms.Cursors]::Hand
$button2pc.Font = New-Object System.Drawing.Font('Microsoft Sans Serif', 7, [System.Drawing.FontStyle]::Regular)
$button2pc.Text = "test B" 
$button2pc.BackColor = "Yellow"
$button2pc.Add_Click({b}) 
$Form.Controls.Add($button2pc) 

$button3pc = New-Object System.Windows.Forms.Button 
$button3pc.Location = New-Object System.Drawing.Size(745,130) 
$button3pc.Size = New-Object System.Drawing.Size(110,40)
$button3pc.Cursor = [System.Windows.Forms.Cursors]::Hand
$button3pc.Font = New-Object System.Drawing.Font('Microsoft Sans Serif', 7, [System.Drawing.FontStyle]::Regular)
$button3pc.Text = "test C" 
$button3pc.BackColor = "Yellow"
$button3pc.Add_Click({c}) 
$Form.Controls.Add($button3pc) 

$outputBox = New-Object System.Windows.Forms.TextBox 
$outputBox.Location = New-Object System.Drawing.Size(20,320) 
$outputBox.Size = New-Object System.Drawing.Size(585,180) 
$outputBox.MultiLine = $True 
$outputBox.ReadOnly = $True
$outputBox.Font = New-Object System.Drawing.Font("Calibri",11,[System.drawing.FontStyle]::Bold)
$outputBox.ForeColor = [Drawing.Color]::Green
$outputBox.ScrollBars = "Vertical" 
$Form.Controls.Add($outputBox) 

$Form.Add_Shown({$Form.Activate()})
[void] $Form.ShowDialog()

Viewing all 21975 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>