Search found 11841 matches

by jvierra
Sun Feb 18, 2018 12:10 pm
Forum: PowerShell GUIs
Topic: ISE vs Jobform
Replies: 10
Views: 140

Re: ISE vs Jobform

Each job calls completed when it is finished. To detect if the current user is an admin on the current machine use this: [bool]([System.Security.Principal.WindowsIdentity]::GetCurrent().Groups |?{$_ -eq 'S-1-5-32-544'}) To find any user in Administrators: [bool](Get-LocalGroupMember administrators |...
by jvierra
Sun Feb 18, 2018 11:36 am
Forum: PowerShell GUIs
Topic: ISE vs Jobform
Replies: 10
Views: 140

Re: ISE vs Jobform

You need to remember that a job cannot reference any controls or variables in the form. All things must be passed as arguments to the job.

The hang was caused by the long timeout with ADSI when trying to access a non-responsive or non-existent computer.
by jvierra
Sun Feb 18, 2018 9:33 am
Forum: PowerShell GUIs
Topic: ISE vs Jobform
Replies: 10
Views: 140

Re: ISE vs Jobform

Many subtle difference. The Invoke works the way I posted it. The job must be launched correctly so I made that more explicit. Look more closely: $jobscript = { Param ($PC) #-------------------------------------------------- #TODO: Set a script block #Important: Do not access form controls from this...
by jvierra
Sun Feb 18, 2018 1:21 am
Forum: PowerShell GUIs
Topic: Getting Datagridview to Populate Correctly
Replies: 2
Views: 52

Re: Getting Datagridview to Populate Correctly

Here is an article from MS showing how to access SQLLite databases from PowerShell using the SQLLite provider.

https://social.technet.microsoft.com/wi ... bases.aspx
by jvierra
Sat Feb 17, 2018 5:23 pm
Forum: PowerShell GUIs
Topic: Getting Datagridview to Populate Correctly
Replies: 2
Views: 52

Re: Getting Datagridview to Populate Correctly

The output of your query is text and not objects. You muse use a command based of OLEDB.Net and the System.Data.OleDbClient. The sqllite EXE cannot create objects.
by jvierra
Sat Feb 17, 2018 7:04 am
Forum: PowerShell GUIs
Topic: ISE vs Jobform
Replies: 10
Views: 140

Re: ISE vs Jobform

I fixed your script. You had a few errors in coding that, when fixed, allowed it to work.
by jvierra
Fri Feb 16, 2018 9:30 pm
Forum: PowerShell GUIs
Topic: ISE vs Jobform
Replies: 10
Views: 140

Re: ISE vs Jobform

Easy way.

if(net user $env:USERNAME | ?{$_ -match 'administrators'}){'Admin'}else{'not admin'}

If you are running this from a login script than any method can take up to 5 minutes. Login scripts are delayed to accelerate the logon process.
by jvierra
Fri Feb 16, 2018 1:25 am
Forum: Windows PowerShell
Topic: need to speedup this script
Replies: 4
Views: 91

Re: need to speedup this script

Example:
$Admins = Get-QADGroup -SearchRoot "$Domain/groups" -LDAPFilter '(CN='Administrative Users)'

This will always be faster the a "Where".
by jvierra
Fri Feb 16, 2018 1:20 am
Forum: Windows PowerShell
Topic: need to speedup this script
Replies: 4
Views: 91

Re: need to speedup this script

The CmdLets would be faster if you used a filter and not a "Where". Using "Where" to filter causes you to return ALL groups everytime.
Also returning all groups once then filter the results would also be faster.
by jvierra
Thu Feb 15, 2018 6:12 pm
Forum: Windows PowerShell
Topic: Variables to CSV at end of Jobs
Replies: 2
Views: 82

Re: Variables to CSV at end of Jobs

The first line of your script is wrong. A key cannot begin with a "$". A job cannot reference controls on a form. $csvfile = "\\server\Projects\$($args[0])\Usage.csv" [PSCustomObject]@{ PCT = $env:username Asset = $env:COMPUTERNAME Date = [datetime]::Now.ToShortDateString() Time = [datetime]::Now.To...