Giter Site home page Giter Site logo

nickrod518 / powershell-scripts Goto Github PK

View Code? Open in Web Editor NEW
317.0 34.0 95.0 257 KB

PowerShell scripts ranging from SCCM, MSO, AD, and other corporate enterprise uses... to sending cat facts to coworkers.

PowerShell 98.91% Shell 1.09%
powershell-script powershell ps1 sccm active-directory microsoft windows automation scripts scripts-collection

powershell-scripts's Introduction

PowerShell-Scripts

Just a bunch of PowerShell scripts for sysadmins.

powershell-scripts's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

powershell-scripts's Issues

Introduce a README.md

Scripts here are wonderful but mostly useless for a noob PowerShell enthusiast.

I believe having a markdown that explains the basic working of PowerShell Scripts or how to get started with them and implement them in your system can work wonders.

TenantDomain detection isn't correct

Regarding: https://github.com/nickrod518/PowerShell-Scripts/blob/master/MSO/OneDrive.psm1

Some assumptions are made with the following statement which are not always true - eg. user email may be [email protected] however the onmicrosoft domain may be different, say companyxy.onmicrosoft.com and the SPO domain is based on this
[string] $TenantDomain = (ConvertTo-Domain $UserPrincipalName)

The following would get the correct name:

    $domains = get-msoldomain                           ## get a list of all domains in tenant
    foreach ($domain in $domains) {                     ## loop through all these domains
        if ($domain.name.contains('onmicrosoft')) {     ## find the onmicrosoft.com domain
            $onname = $domain.name.split(".")           ## split the onmicrosoft.com domain when found at the period. Will produce an array that contains each string as an element
            $tenantname = $onname[0]                    ## the first string in this array is the name of the tenant
        }                                               ## end of find the on.microsoft.com domain
    }          

Send-CatFactMessage.ps1

IWR returns:

Invoke-WebRequest : Python 2.5 is no longer available. Please refer to https://goo.gl/aESk5L for more information. At line:45 char:35
+ ... tFrom-Json (Invoke-WebRequest -Uri 'http://catfacts-api.appspot.com/a ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Finding 'exe' directory (Windows Server OS)

This may not be an issue so much as unexpected behavior for the lay person-

OS: Windows Server 2012 R2
Powershell version: 4
Issue: Using the variable $PSScriptRoot in the powershell script before exe wrapping (the system variable normally stores root directory where script is executed from).
Expected behavior: Variable stores path where powershell file is ran from (which works, but not as you'd think).
Observed behavior: Variable stores temp variable path where exe extracts to, under C:\Users\AppData\Local\Temp\2\IXP001.TMP. (also where powershell file is found and left there after the exe completes).

Ideally this copied ps1 file would be cleaned up by the exe once the process completes, i'd imagine.

Having a way to reference where the exe ran from inside the powershell script would be nice as well, but I can't imagine a powershell script can talk outside the exe's scope.
Running [Reflection.Assembly]::GetExecutingAssembly().Location displays a 'blank' in the location field as well.

Script to test:
image

Output (log files removed up):
image

Unable to import servermanager module in EXE, but works in ps1

Exe unable to find servermanager module but ps1 file equivalent is able to.

To reproduce:

Run this code in a ps1 script:
import-module servermanager
get-module
Read-Host

Run 'Create-EXEFrom' on this ps1 script.
Copy both ps1 file and exe to Windows Server 2012.
See attachment for results when both are executed. The exe throws a terminating error of 'FileNotFound' for some reason.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.