webui/aduser.ps1
Get-SkParams $PageTitle = "AD User" if (![string]::IsNullOrEmpty($Script:SearchValue)) { $PageTitle += ": $($Script:SearchValue)" } $content = "" $menulist = "" $tabset = "" $pagelink = Split-Path -Leaf $MyInvocation.MyCommand.Definition switch ($TabSelected) { 'General' { try { $user = Get-SkAdUsers | Where-Object {$_.UserName -eq "$SearchValue"} $columns = $user.psobject.properties | Select-Object -ExpandProperty Name $content = "<table id=table2>" foreach ($col in $columns) { $fvx = Get-SkValueLinkAD -PropertyName $col -Value $($user."$col" | Out-String) $content += "<tr><td class=`"t2td1`">$col</td><td class=`"t2td2`">$fvx</td></tr>" } $content += "</table>" } catch { $content = "<table id=table2><tr><td>Error: $($Error[0].Exception.Message)</td></tr></table>" } break; } 'Computers' { $params = @{ QueryFile = "cmuserdevices.sql" PageLink = $pagelink Columns = ('ComputerName','ProfilePath','TimeStamp','ResourceID','ADSite') Sorting = 'ComputerName' NoUnFilter = $True } $xxx = "queryfile: cmuserdevices.sql" $content = Get-SkQueryTableMultiple @params break; } 'Collections' { try { $SearchField = 'UserName' $params = @{ QueryFile = "cmusercolls.sql" PageLink = $pagelink Columns = ('CollectionID','CollectionName') Sorting = 'CollectionName' NoUnFilter = $True NoCaption = $True } $content = Get-SkQueryTableMultiple @params $resid = Get-SkCmObjectName -TableName "v_R_User" -SearchProperty "User_Name0" -SearchValue $Script:SearchValue -ReturnProperty "ResourceID" if ($SkCmCollectionManage -eq 'TRUE') { $dcolls = Get-SkCmUserCollectionMemberships -UserName $Script:SearchValue -Inverse if ($dcolls.count -gt 0) { $content += "<form name='form1' id='form1' method='post' action='addmember.ps1'> <input type='hidden' name='resname' id='resname' value='$CustomName' /> <input type='hidden' name='resid' id='resid' value='$resid' /> <input type='hidden' name='restype' id='restype' value='4' /> <table id=table2><tr><td> <select name='collid' id='collid' size=1 style='width:500px;padding:5px'> <option value=`"`"></option>" foreach ($row in $dcolls) { $cid = $row.CollectionID $cnn = $row.Name $content += "<option value=`"$cid`:$cnn`">$cnn</option>" } $content += "</select> <input type='submit' name='ok' id='ok' value='Add' class='button1' /> (direct membership collections only)</td></tr></table></form>" } } } catch { $content = "<table id=table2><tr><td>Error: $($Error[0].Exception.Message)</td></tr></table>" } break; } 'Groups' { $content = "<table id=table1>" $content += "<tr><th>Name</th><th>LDAP Path</th><th></th></tr>" try { $groups = Get-SkAdUserGroups -UserName "$SearchValue" $rowcount = 0 $groups | ForEach-Object { $rmvlink = "<a href=`"admod2.ps1?userid=$SearchValue&groupid=$($_.Name)&op=delmember`" title=`"Remove from Group`">Remove</a>" $content += "<tr>" $xlink = "<a href=`"adgroup.ps1?f=name&v=$($_.Name)&x=equals`" title=`"Details`">$($_.Name)</a>" $content += "<td style=`"width:250px`">$xlink</td>" $content += "<td>$($_.DN)</td>" $content += "<td style=`"width:80px;text-align:center;`">$rmvlink</td>" $content += "</tr>" $rowcount++ } if ($rowcount -gt 0) { $content += "<tr><td colspan=`"3`" class=`"lastrow`">$rowcount groups found</td></tr>" } else { $content += "<tr><td colspan=`"3`" style=`"text-align:center`">No groups found</td></tr></table>" } $content += "</table><br/>" $content += "<form name=`"form11`" id=`"form11`" method=`"POST`" action=`"admod.ps1`">" $content += "<input type=`"hidden`" name=`"userid`" id=`"userid`" value=`"$SearchValue`" />" $content += "<input type=`"hidden`" name=`"op`" id=`"op`" value=`"addmember`" />" $content += "<input type=`"submit`" name=`"ok`" id=`"ok`" value=`"Add to Group`" class=`"button1`" title=`"Add to Group`"/>" $content += "</form>" } catch {} break; } } $tabs = @('General','Groups','Computers','Collections') $tabset = Write-SkMenuTabSetNameList -MenuTabs $tabs -BaseLink $pagelink $content += Write-SkDetailView -PageRef $pagelink -Mode $Detailed Write-SkWebContent |