Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all 15028 articles
Browse latest View live

Working with the Certificate PSProvider and managing the "currentuser"and "localmachine" cert store for the logged on user

$
0
0

I am trying to use the remove-item cmdlet with -credential parameter to manage certificates on a computer where the logged-on user does not have any permissions. I am trying to do the following but get an error

$creds = Get-Credential
$certsuser = gci "cert:currentuser\my" | where {$_.subject -like "*something.com*"}
$Block1 = {$certsuser | %{remove-item -path $_.PsPath -recurse -force -Credential $creds}}

start-job -scriptblock $Block1

I get the error that the -credential parameter is not supported by the Provider, I am assuming it is referring to The Certificate PSProvider.

Any thoughts on how I can accomplish this. Thanks

PS. I am using PS2.0 on a Windows 7 workstation.


Directory tree

$
0
0

How can I get a directory listing of directories and sub-directories using a batch file but I want to exclude the directory name. I've tried the following 

dir /s/b/o:n/a:d > Listings.txt 

but I seem to still get the directory path included

Repeating header in Weekend Scripter: How Can I Create, Display, and Then Delete a Temporary Text File?

$
0
0

It seems that the script output repeats the header line for each item in the pipeline. In case of "dir c:\windows | out-tempfile" it actually prints multiple lines before each item.

It is not obvious why. I tried debugging the script and each items comes without the header line (s).

Thank you

Alex.

Different results on the DC

$
0
0

Hello

I created a script and tested it from my workstation, only to find that some expected return values no longer worked when running it on the DC.

The values that come up missing are EmployeeID and EmployeeNumber (employeeType doesn't work properly either, but I am not interested in it for this script).  To test, I went to Powershell and ran commands individually.

I am running as a service account, so did my testing as that service account from both my workstation and the DC.  The script and the manual commands all work on the workstation and fail on the DC.

First to run in the context of the service account:
Start-Process powershell.exe -Credential "Domain\ServiceAccount"

This opens a new window where I enter the command that I am having issues with:
Get-ADUser Bob.Smith -Properties * | fl Name,Employee*

On the workstation (and on a member server), it returns:
Name        :  Bob Smith
EmployeeID    :  123456
EmployeeNumber    :  987643
EmployeeType    :  Employee

On the DC, it returns (NOTE - employeeType doesn't return at all):
Name        :  Bob Smith
EmployeeID    :  
EmployeeNumber    :  

Any ideas are appreciated!

Thanks

UPDATE NOTE:  I also tested on a member server and the results are the same as the workstation, so the issue appears to be isolated to the DC

If someone could help and RSVP I would be so happy!

$
0
0
I cant change the input on my PC to make it HDMI so that I can play my xbox one on my PC screen.

Windows Update PowerShell Module -- Win 7 Requirement

$
0
0

This powershell module, as described on this page:

Windows Update PowerShell Module

Actually MUST have PowerShell 3.0

The pre-requisites are wrong, it says that only PowerShell 2.0 is required.

There is a call to an "Ublock" function, but that was first available in PS 3.0.


Powershell Help - Moving disabled accounts

$
0
0

Came across this script posted a while back that is what I am looking for to remove disabled accounts.  However I am trying to tweak it so that I can move disabled accounts after 30 days of disabling/no activiity into it's own OU.  Here's the original link...

https://gallery.technet.microsoft.com/scriptcenter/Disabled-AD-Account-8cc92a7d#content

I'm stuck on moving the user object, ANY help would be appreciated.  Thanks!


#load AD module 
import-module activedirectory 
 
$oldDate = [DateTime]::Today.AddDays(-30) 
$warnDate = [DateTime]::Today.AddDays(-23) 
$AMSearchBase = "OU=Users,OU=Accounts,DC=Corp,DC=Com" 
$ShortRegion = "IT" 
$Region = "Information Technology" 
$disabledUsers = @() 
$warnUsers = @() 
$wlistUsers = @() 
$30daysUsers = @() 
 
##AM Section## 
##Retrieves disabled user accounts and stores in an array 
$disabledUsers = Get-ADUser -filter {(Enabled -eq $False)} -Searchbase $AMSearchBase -Searchscope 1 -Properties Name,SID,Enabled,LastLogonDate,Modified,info,description 
 
foreach ($name in $disabledUsers) { 
    if ($name.info -ne "WHITELIST" -and $name.modified -le $oldDate) { 
        Get-ADUser -Filter $disabledUsers | Move-ADObject -targetpath "OU=Disabled Accounts,OU=Users,OU=Accounts,DC=Corp,DC=Com"
        $disabledUsers = $disabledUsers + $name 
        } 
    elseif ($name.info -eq "WHITELIST") { 
        #Write-Host $name.name " is Whitelisted" 
        $wlistUsers = $wlistUsers + $name 
        } 
        elseif ($name.info -ne "WHITELIST"-and $name.modified -le $warnDate) { 
        #Write-Host $name.name " is will be deleted in the next run" 
        $warnUsers = $warnUsers + $name 
        } 
    else {
        #Write-Host $name.name " was modified less than 30 days ago" 
        $30daysUsers = $30daysUsers + $name 
        } 

 
$report = "c:\Scripts\Reports\DisabledAccounts30Days.htm"  
##Clears the report in case there is data in it 
Clear-Content $report 
##Builds the headers and formatting for the report 
Add-Content $report "<html>"  
Add-Content $report "<head>"  
Add-Content $report "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"  
Add-Content $report '<title>COMPANY Terminated User Cleanup Script</title>'  
add-content $report '<STYLE TYPE="text/css">'  
add-content $report  "<!--"  
add-content $report  "td {"  
add-content $report  "font-family: Tahoma;"  
add-content $report  "font-size: 11px;"  
add-content $report  "border-top: 1px solid #999999;"  
add-content $report  "border-right: 1px solid #999999;"  
add-content $report  "border-bottom: 1px solid #999999;"  
add-content $report  "border-left: 1px solid #999999;"  
add-content $report  "padding-top: 0px;"  
add-content $report  "padding-right: 0px;"  
add-content $report  "padding-bottom: 0px;"  
add-content $report  "padding-left: 0px;"  
add-content $report  "}"  
add-content $report  "body {"  
add-content $report  "margin-left: 5px;"  
add-content $report  "margin-top: 5px;"  
add-content $report  "margin-right: 0px;"  
add-content $report  "margin-bottom: 10px;"  
add-content $report  ""  
add-content $report  "table {"  
add-content $report  "border: thin solid #000000;"  
add-content $report  "}"  
add-content $report  "-->"  
add-content $report  "</style>"  
Add-Content $report "</head>"  
add-Content $report "<body>"  
 
##This section adds tables to the report with individual content 
##Table 1 for deleted users 
add-content $report  "<table width='100%'>"  
add-content $report  "<tr bgcolor='#CCCCCC'>"  
add-content $report  "<td colspan='7' height='25' align='center'>"  
add-content $report  "<font face='tahoma' color='#003399' size='4'><strong>The following users have been moved to the Disabled OU (Report Only)</strong></font>"  
add-content $report  "</td>"  
add-content $report  "</tr>"  
add-content $report  "</table>"  
add-content $report  "<table width='100%'>"  
Add-Content $report "<tr bgcolor=#CCCCCC>"  
Add-Content $report  "<td width='20%' align='center'>Account Name</td>"  
Add-Content $report "<td width='10%' align='center'>Modified Date</td>"   
Add-Content $report "<td width='50%' align='center'>Description</td>"   
Add-Content $report "</tr>"  
if ($disabledUsers -ne $null){ 
    foreach ($name in $disabledUsers) { 
        $AccountName = $name.name 
        $LastChgd = $name.modified 
        $UserDesc = $name.Description 
        Add-Content $report "<tr>"  
        Add-Content $report "<td>$AccountName</td>"  
        Add-Content $report "<td>$LastChgd</td>"  
        add-Content $report "<td>$UserDesc</td>" 
    } 

else { 
    Add-Content $report "<tr>"  
    Add-Content $report "<td>No Accounts match</td>"  

Add-content $report  "</table>"  
 
##Table 2 for warning users 
add-content $report  "<table width='100%'>"  
add-content $report  "<tr bgcolor='#CCCCCC'>"  
add-content $report  "<td colspan='7' height='25' align='center'>"  
add-content $report  "<font face='tahoma' color='#003399' size='4'><strong>The following users will be moved to the Disabled OU next week</strong></font>"  
add-content $report  "</td>"  
add-content $report  "</tr>"  
add-content $report  "</table>"  
add-content $report  "<table width='100%'>"  
Add-Content $report "<tr bgcolor=#CCCCCC>"  
Add-Content $report  "<td width='20%' align='left'>Account Name</td>"  
Add-Content $report "<td width='10%' align='center'>Modified Date</td>"   
Add-Content $report "<td width='50%' align='center'>Description</td>"   
Add-Content $report "</tr>" 
if ($warnUsers -ne $null){ 
    foreach ($name in $warnUsers) { 
        $AccountName = $name.name 
        $LastChgd = $name.modified 
        $UserDesc = $name.Description 
        Add-Content $report "<tr>"  
        Add-Content $report "<td>$AccountName</td>"  
        Add-Content $report "<td>$LastChgd</td>"  
        add-Content $report "<td>$UserDesc</td>" 
    } 

else { 
    Add-Content $report "<tr>"  
    Add-Content $report "<td>No Accounts match</td>"  

Add-content $report  "</table>"  
 
##Table 3 for whitelisted users 
add-content $report  "<table width='100%'>"  
add-content $report  "<tr bgcolor='#CCCCCC'>"  
add-content $report  "<td colspan='7' height='25' align='center'>"  
add-content $report  "<font face='tahoma' color='#003399' size='4'><strong>The following users are whitelisted</strong></font>"  
add-content $report  "</td>"  
add-content $report  "</tr>"  
add-content $report  "</table>"  
add-content $report  "<table width='100%'>"  
Add-Content $report "<tr bgcolor=#CCCCCC>"  
Add-Content $report  "<td width='20%' align='left'>Account Name</td>"  
Add-Content $report "<td width='10%' align='center'>Modified Date</td>"   
Add-Content $report "<td width='50%' align='center'>Description</td>"   
Add-Content $report "</tr>" 
if ($wlistUsers -ne $null){ 
    foreach ($name in $wlistUsers) { 
        $AccountName = $name.name 
        $LastChgd = $name.modified 
        $UserDesc = $name.Description 
        Add-Content $report "<tr>"  
        Add-Content $report "<td>$AccountName</td>"  
        Add-Content $report "<td>$LastChgd</td>"  
        add-Content $report "<td>$UserDesc</td>" 
    } 

else { 
    Add-Content $report "<tr>"  
    Add-Content $report "<td>No Accounts match</td>"  

Add-content $report  "</table>"  
 
##Table 4 for recently modified users 
add-content $report  "<table width='100%'>"  
add-content $report  "<tr bgcolor='#CCCCCC'>"  
add-content $report  "<td colspan='7' height='25' align='center'>"  
add-content $report  "<font face='tahoma' color='#003399' size='4'><strong>The following disabled users were modified in the last 30 days</strong></font>"  
add-content $report  "</td>"  
add-content $report  "</tr>"  
add-content $report  "</table>"  
add-content $report  "<table width='100%'>"  
Add-Content $report "<tr bgcolor=#CCCCCC>"  
Add-Content $report  "<td width='20%' align='left'>Account Name</td>"  
Add-Content $report "<td width='10%' align='center'>Modified Date</td>"   
Add-Content $report "<td width='50%' align='center'>Description</td>"   
Add-Content $report "</tr>"  
if ($30daysUsers -ne $null){ 
    foreach ($name in $30daysUsers) { 
        $AccountName = $name.name 
        $LastChgd = $name.modified 
        $UserDesc = $name.Description 
        Add-Content $report "<tr>"  
        Add-Content $report "<td>$AccountName</td>"  
        Add-Content $report "<td>$LastChgd</td>"  
        add-Content $report "<td>$UserDesc</td>" 
    } 

else { 
    Add-Content $report "<tr>"  
    Add-Content $report "<td>No Accounts match</td>"  

Add-content $report  "</table>"  
 
##This section closes the report formatting 
Add-Content $report "</body>"  
Add-Content $report "</html>"  
 
##Assembles and sends completion email with DL information## 
$emailFrom = "ADManagement@corp.com" 
$emailTo = "test@corp.com" 
$subject = "Corp $Region Disabled User Cleanup Script Complete" 
$smtpServer = "ismtp.corp.com" 
$body = Get-Content $report | Out-String 
 
Send-MailMessage -To $emailTo -From $emailFrom -Subject $subject -BodyAsHtml -Body $body -SmtpServer $smtpServer 

How do I get a VBScript to send a parameter value to sql sp

$
0
0

I want the user to enter the month into the input box: Example: Nov

My parameter in sql is named: @Commissionsmonth

I know my sp works if ran within sql.  Any help with this would be greatly appreciated!

returnvalue=MsgBox ("ARE YOU SURE YOU WANT TO UPDATE COMMISSIONS PAID?",36,"CONFIRM UPDATE!!")
If returnvalue=6 Then
Dim cmd
Dim sp
sp = "asp_update_commissions_paid"
Set cmd = CreateObject("ADODB.Command")
With cmd
.ActiveConnection = "Provider=sqloledb;Data Source=myserver;Initial Catalog=mydatabase;Integrated Security=SSPI"
 .CommandType = 4
 .CommandText = sp


sInput = InputBox("Enter Month being Paid")

returnvalue=MsgBox ("Commissions Paid has been updated",36,"CONFIRM UPDATE!!")
 .Execute
End With
Set cmd = Nothing
End If

 


Power shell null value

$
0
0

I'm trying to create multiple users at once i create the CSV file and .PS1 file 

when i'm try to execute in powe shell i get this message    (

You cannot call a method on a null-valued expression.
At C:\bin\scripts\addusers.ps1:13 char:13
+ $objUser.Put <<<< ("userPrincipalName",$userPrincipalName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

any one help me

thank you  

File Extension Search

$
0
0

Hi

I have a script to search for .pst from a computer list and save the output list in .csv file, I would like to use the same script to search from multiple file extension i.e. doc,xls,….etc.

Below the script I’m using

$strComputers = Get-Content -Path "C:\computernames.txt"
[bool]$firstOutput = $true
foreach($strComputer in $strComputers)
{
$colFiles = Get-Wmiobject -namespace "root\CIMV2" `
-computername $strComputer `
-Query "Select * from CIM_DataFile `
where Extension = 'xlsx' "

foreach ($objFile in $colFiles)
{
if($objFile.FileName -ne $null)
{
$filepath = $objFile.Drive + $objFile.Path + $objFile.FileName + "." `
+ $objFile.Extension;
$query = "ASSOCIATORS OF {Win32_LogicalFileSecuritySetting='" `
+ $filepath `
+ "'} WHERE AssocClass=Win32_LogicalFileOwner ResultRole=Owner"

$colOwners = Get-Wmiobject -namespace "root\CIMV2" `
-computername $strComputer `
-Query $query
$objOwner = $colOwners[0]
$user = $objOwner.ReferencedDomainName + "\" + $objOwner.AccountName
$output = $strComputer + "," + $filepath + "," + $user + "," + $objFile.FileSize/1KB + "," + $objFile.LastModified
if($firstOutput)
{
Write-output $output | Out-File -Encoding ascii -filepath "C:\msofficedetails.csv"
$firstOutput = $false
}
else
{
Write-output $output | Out-File -Encoding ascii -filepath "C:\msofficedetails.csv" -append
}
}
}
}

Power shell scripting for push files recursively to ftp server

$
0
0

Hi,

I want to copy all the files ,folders and subfolders to ftp server

I tried with below script

## Automate FTP uploads
## Go to destination
cd d:/test
$location = Get-Location
"We are here: $location"
## Get files
$files = $files=Get-ChildItem -recurse
## Get ftp object
$ftp_address = ftp://test.ftp.azurewebsites.windows.net/
$user = "username"
$pass = "Password"
$ftp_client = New-Object System.Net.WebClient

$webclient.Credentials = New-Object System.Net.NetworkCredential($user.Normalize(),$pass.Normalize()) 
## Make uploads
foreach($file in $files)
{
   
    $directory = "";
    $source = $file.DirectoryName + "\" + $file;

    if ($File.DirectoryName.Length -gt 0)
    {
        $directory = $file.DirectoryName.Replace($Location,"")
    }
    $directory += "/";
    $FtpCommand = $ftp_address + $directory
  
 
    $makeDirectory = [System.Net.FtpWebRequest]::Create($ftp_address+$directory);
    $makeDirectory.Credentials = New-Object System.Net.NetworkCredential($user,$pass);
    $makeDirectory.Method = [System.Net.WebRequestMethods+FTP]::MakeDirectory;
    $makeDirectory.GetResponse();

    $uri = New-Object System.Uri($FtpCommand+$file.Name)
    "Command is " + $uri+ " file is $source"
    $ftp_client.UploadFile($uri, $file.FullName)
}

but it throwing the below error

Exception calling "UploadFile" with "2" argument(s): "The remote server returned an error: (530) Not logged in."
At C:\ftp.ps1:39 char:5
+     $ftp_client.UploadFile($uri, $file.FullName)}
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException

but it is creating a folder in my ftp server. if i remove the folder creation script code it is moving the files under main folder. it is not coping the subfolder and files.

can any one help me to resolve this issue.


Regards, Kasani Anvesh


Set-ACL - Method Failed with error code 1337

$
0
0

Hello everyone,

I am writing a code that searches through our folders and finds home drives and profiles that do not have a corresponding AD object and delete them, i.e. for people that have left and their profile was never deleted. I am using the following script to run against one user and I keep getting the errors : Method Failed with error code 1337.

this is underlined in RED for the error: Set-acl -path "$Folderpath" -aclobject $currentACL

Error: the data area passed to the system is too small

this is underlined in RED for the error: Takeown.exe /f "$folderpath" /R /D Y /A

 

Function Get-ACLError($Folder){

$Error.clear()

$Errorarray = @()

get-childitem "$Folder" -Recurse -erroraction silentlycontinue | select Fullname

     IF($error){

      $errorarray = $error + $errorarray

       foreach($err in $errorarray){

        if($err.fullyqualifiedErrorID -eq "DirUnathorizedAccessError,Microsoft.Powershell.Command.Getchilditem"){

         Write-host "Unable to Access $Err.TargetObject" -foregroundcolor yellow

            Take-ownership($err.TargetObject)

            Get-ACLError($err.TargetObject)

          }

        }

      }

  }

 

Function Take-Ownership{

     param(

     [string]$folderpath

     )

     Takeown.exe /F "$folderpath" /R /D Y /A

     $currentACL + Get-ACL "$folderPath"

     Write-host "..Adding Admin to $Folderpath" -fourgroundcolor yellow

     $systemACLPermissions = "Administrator","Fullcontrol","containerinherit,objectinherit","none","allow"

     $systemaccessrule = new-object system.security.accesscontrol.filesystemaccessrule $systemACLPermission

     $currentACL.addaccessrule($systemaccessrule)

     write-host "..adding Infrastructure to "Folderpath" -fourgroundcolor yellow

     $adminACLPermission = "mydomain","fullcontrol",containerinherit,objectinherit","none","allow"

     $systemaccessrule = new-object system.security.accesscontrol.filesystemaccessrule $adminACLPermission

     $currentACL.addaccessrule($systemaccessrule)

     Set-ACL -path "$Folderpath" -Aclobject $currentACL

}

 Take-ownership "XXXX\home\(SID)" -recurse |get-aclerror; remove-item "XXXX\home\(SID)"

Any help would be appreciated.




preform action on each word separated by commas

$
0
0

I have done this before but I have spent an hour on this and I am just frusterated I should be able to do this.  aggg.

I have a huge list sent to me just like this/

500, 200032 , 700895, 20008787, ECT, ECT

It may be 1000's of numbers.  I need to preform a simple action on each number

I see it is drong.  I have goggled it as I Know this is wrong I cant for the life of me remember what I need to do. 

so ....

$numbers = "500, 200032 , 700895, 20008787, ECT, ECT"


foreach ($number in $numbers) {

"Do something to $number"


}

Please help 


Lishron

VBScript Logging

$
0
0

Hello,

I have a log that I use during logon that captures certain information (time/date, computer name, user name, ip and mac address etc. and has been working well for me to date. However, I have had need on occasion to use these routines for other tasks I was assigned to do. I need to be able to (of course) log each login event, however, I would like it to search for a previous entry (via computer name) and instead of creating a new entry, to modify the previous entry with new logon information, and I am not sure how to accomplish this. Can you provide me with a way to update an existing entry based upon the computer name?

Here is some of the code I'm using at the moment, its pretty basic but gets the job done.

Sub LogIt()

Path = "\\Server\share\Logon Info.csv"
    Const ForReading = 1
    Const ForWriting = 2
    Const ForAppending = 8

If fso.FileExists(Path)= 0Then
    'Log File not found - Create Log File 
    Set oFile = fso.CreateTextFile(Path, True) 
    oFile.WriteLine("Date & Time" & "," & "Computer Name" & "," & "NT User ID" & "," & "First Name" & "," & "Last Name" & "," & "Operating System" & "," & "Version" & "," & "IP Address" & "," & "Mac Address" & vbCrLf) 
    oFile.Close
    WScript.Sleep(500)
EndIf
    Set oFile = fso.OpenTextFile(Path, ForAppending)
    oFile.Write(Now() & "," & strComputer & "," & strUserName & "," & strGivenName & "," & oUser.sn & "," & strCaption & "," & strArch  & "," & strIP & "," & strMac & vbCrLf) 
    oFile.Close


EndSub

Any help would be appreciated.

Combine Multiple CSV Files into Large CSV Files

$
0
0

I have a BUNCH of csv files that I'd like to condense into fewer files however I'd like to create a new file each time a file reaches 1,000,000 rows. So I'd end up with something like "outputfile-1.csv" that contains a million rows, then "output-2.cvs" containing the next 1 million rows and so on. How can this be accomplish?

I have (gc *.csv) | set-content output.cvs

And that works but I don't know how to make it only do 1 million rows per csv file.


John Marcum | Microsoft MVP - Enterprise Client Management
My blog: System Center Admin | Twitter:@SCCM_Marcum | Linkedin: John Marcum


3 - Powershell commands to accomplish tasks

$
0
0

    I have a customer, with Office365, and they have a 'master calendar' as a room mailbox.  Their vendor has given us these three things that must be set in powershell to the calendar, but I cannot find the specific commands to run, and I'm not that saavy with scripting, so I am reaching out to the experts!!

    1. Set the calendar to auto accept events, even if conflicting
    2. Set calendar to display the details instead of “busy”
    3. Set it to show the creator

    Any help would be appreciated.

    Ask for Input and Use Input in the Next Command

    $
    0
    0

    Hi Everyone,

    I am not very god at scripting and need a bit of your help.

    I have a command hat I plan on using to get a remote computesr's OS version and installed patches. 

    I can use a txt file with the computer name to be queried, but I thought it would be even easier for the batch file to ask me for input so I enter the computer name and once I enter it, it uses it for the next command.

    Here is the code I have so far:

    @echo off

    set /p CompName= Enter name of computer? %Compname% > c:\computers.txt

    wmic  /node:@c:\computers.txt  os get Caption,CSDVersion /value /format:htable >> C:\OSnPatches.htm  & wmic /node:@c:\computers.txt qfe list full /format:htable >> C:\OSnPatches.htm


    Can you help me get the CompName variable be used in the WMIC query?

    Thanks in advance,

    S

    PowerShell Script to Check Remote Server Ping and Trigger SQL AOAAG Failover if remote server is down

    $
    0
    0

    Hi,

    our requirement is to have a powershell script that checks ping status of a remote server and trigger or execute MSSQL AOAag Failover using powershell script.

    to begin with I have this below script that pings the remote server, so if reply fails then we want to execute db failover. how to do? the script will run on MSSQL AOAAG itself

    =============

    Test-Connection-ComputerNamens1-xms1.dm.com

    if fails

    then execute db failover.

    =================================

    Windows 7 x64 property of a registry value

    $
    0
    0

    Hello,

    I am using this script to detect differen Versions of which I want to delete.

    The script is normaly working, but now I am having a problem on my Windows 7 x64 test Computer.

    I want to catch the PSChild value of the current object but it is not work. I can't get any value.

    ((Get-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.Publisher -like  $vApplicationVendor+"*" -and $_.DisplayName -like  $vApplicationName+"*"}).PSChildName)

    When I try it on another Computer with Windows 7 x64 then it is working.

    Both computers are fully patched and havinf PS 2.0.

    ################################################
    #Unsinstall Script                             #
    #by Florian zepter                             #
    #Version 1.0                                   #
    ################################################
    #Edit here:                                    #
    #enter name and vendor (publisher) of the app  #
    #Put the names into ''                         #
    ################################################
    
        $vApplicationName = 'Brava!'
        $vApplicationVendor = 'IGC'
        #$vApplicationVersion = '11.0.0'
    
    ################################################
    #no changes here!!!                            #
    #Uninstall function                            #
    ################################################
    
    #selection all the prducts where condition is suitable
    # get the msi product codes
        $vApplictaionDetect = @(
                                ((Get-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.Publisher -like  $vApplicationVendor+"*" -and $_.DisplayName -like  $vApplicationName+"*"}).PSChildName)
                                ,
                                ((Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.Publisher -like  $vApplicationVendor+"*"}).PSChildName)
                               )
    
        # remove software
        $vApplictaionDetect | ForEach-Object {if (!$_) {} else {Start-Process msiexec.exe -ArgumentList /x, $_, /qn -wait -passthru}}

    Find users without customattribute1 set

    $
    0
    0

    I can't figure out how to get a list of users who don't have customattribute1 set to employee.  I'm very new to scripting so be gentle.  :)

    My latest attempt

     Get-ADUser -filter * -Properties * | ? {$_.customattribute1 -notlike employee}

    Any ideas/help?

    Thanks!!

    Viewing all 15028 articles
    Browse latest View live


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